Convert output from MD5 to printable ascii

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • santosh

    #16
    Re: OT - Re: Convert output from MD5 to printable ascii


    Ben Pfaff wrote:
    "santosh" <santosh.k83@gm ail.comwrites:
    >
    Interestingly, over here, (gcc 4.0.3 on an i686 Linux), gcc will emit
    a call to puts for the corresponding printf invocation when the first
    argument contains no format specifiers. This is done even when
    optimisations are disabled.
    >
    I hope it does that only when the format string ends in a
    new-line character.
    It seems to do as you say. Why that requirement?

    Comment

    • Joachim Schmitz

      #17
      Re: OT - Re: Convert output from MD5 to printable ascii

      "santosh" <santosh.k83@gm ail.comschrieb im Newsbeitrag
      news:1172393796 .270714.251430@ m58g2000cwm.goo glegroups.com.. .
      >
      Ben Pfaff wrote:
      >"santosh" <santosh.k83@gm ail.comwrites:
      >>
      Interestingly, over here, (gcc 4.0.3 on an i686 Linux), gcc will emit
      a call to puts for the corresponding printf invocation when the first
      argument contains no format specifiers. This is done even when
      optimisations are disabled.
      >>
      >I hope it does that only when the format string ends in a
      >new-line character.
      >
      It seems to do as you say. Why that requirement?
      Because puts() appends a newline to the string it prints. It printf() hadn't
      been told to add a newline, and would use puts() to do the printing, that
      would add a newline, rendering the printf() behavoir non-conforming.

      Bye, Jojo


      Comment

      • Flash Gordon

        #18
        Re: OT - Re: Convert output from MD5 to printable ascii

        santosh wrote, On 25/02/07 08:56:
        Ben Pfaff wrote:
        >"santosh" <santosh.k83@gm ail.comwrites:
        >>
        >>Interestingly , over here, (gcc 4.0.3 on an i686 Linux), gcc will emit
        >>a call to puts for the corresponding printf invocation when the first
        >>argument contains no format specifiers. This is done even when
        >>optimisatio ns are disabled.
        >I hope it does that only when the format string ends in a
        >new-line character.
        >
        It seems to do as you say. Why that requirement?
        Because puts appends a newline character, so it can't be used when you
        want to print a partial line not ending in a newline (possibly because
        some other part of the program will print the rest of the line).
        --
        Flash Gordon

        Comment

        • santosh

          #19
          Re: OT - Re: Convert output from MD5 to printable ascii

          Flash Gordon wrote:
          santosh wrote, On 25/02/07 08:56:
          Ben Pfaff wrote:
          "santosh" <santosh.k83@gm ail.comwrites:
          >
          >Interestingl y, over here, (gcc 4.0.3 on an i686 Linux), gcc will emit
          >a call to puts for the corresponding printf invocation when the first
          >argument contains no format specifiers. This is done even when
          >optimisation s are disabled.
          >
          I hope it does that only when the format string ends in a
          new-line character.
          It seems to do as you say. Why that requirement?
          >
          Because puts appends a newline character, so it can't be used when you
          want to print a partial line not ending in a newline (possibly because
          some other part of the program will print the rest of the line).
          Thanks. I see it now.

          Comment

          • Randy Howard

            #20
            Re: Convert output from MD5 to printable ascii

            On Sat, 24 Feb 2007 22:13:21 -0600, websnarf@gmail. com wrote
            (in article <1172376801.654 074.324240@j27g 2000cwj.googleg roups.com>):
            On Feb 24, 1:42 pm, Keith Thompson <k...@mib.orgwr ote:
            >websn...@gmail .com writes:
            >>However, I would, of course, just do this:
            >>char out[33], *p;
            >>for (p=out,i=0; i < 16; i++) {
            >>*p++ = "0123456789ABCD EF"[(pout[i] >4) & 0xf];
            >>*p++ = "0123456789ABCD EF"[pout[i] & 0xf];
            >>}
            >>*p = '\0';
            >>puts (out);
            >>
            >>to avoid linking in all of printf() unnecessarily.
            >>
            >I presume you would first confirm that (a) the use of puts() doesn't
            >cause printf() to be linked in anyway on target implementations of
            >interest,
            >
            Well, I don't know what quality of implementations you are used to.
            All the compilers I use basically do link these seperately. The
            reason is that printf is a gargantuan link-in in comparison to puts.
            I just tried this with gcc 4.0.1 using gcc on a Hello, World program
            with printf and puts on OS X. The output size is exactly the same.
            So, I used a slightly trickier printf() call that shouldn't be switched
            out to a straight puts(), and that output file went up by 4284 bytes.

            Outside of embedded land, that is completely meaningless.

            --
            Randy Howard (2reply remove FOOBAR)
            "The power of accurate observation is called cynicism by those
            who have not got it." - George Bernard Shaw





            Comment

            Working...