@@ -591,30 +591,30 @@ static void initValue(long lng_val) {
591591int i ,div ,dig ;
592592char tmp [2 ]= " " ;
593593
594- // set some obvious things
594+ /* set some obvious things */
595595value .val = lng_val >=0 ?lng_val :lng_val * (-1 );
596596value .sign = lng_val >=0 ?'+' :'-' ;
597597value .maxdigits = log10 (2 )* (8 * sizeof (long )-1 );
598598
599- // determine the number of digits
599+ /* determine the number of digits */
600600for (i = 1 ;i <=value .maxdigits ;i ++ ) {
601601if ((int )(value .val /pow (10 ,i ))!= 0 ) {
602602value .digits = i + 1 ;
603603}
604604}
605605value .remaining = value .digits ;
606606
607- // convert the long to string
607+ /* convert the long to string */
608608value .val_string = (char * )malloc (value .digits + 1 );
609609for (i = value .digits ;i > 0 ;i -- ) {
610610div = pow (10 ,i );
611611dig = (value .val %div ) / (div /10 );
612612tmp [0 ]= (char )(dig + 48 );
613613strcat (value .val_string ,tmp );
614614 }
615- // safety-net
615+ /* safety-net */
616616value .val_string [value .digits ]= '\0' ;
617- // clean up
617+ /* clean up */
618618free (tmp );
619619}
620620
@@ -641,34 +641,38 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
641641int i ,j ,k ,dotpos ;
642642int leftalign = 0 ,blank = 0 ,sign = 0 ,entity = 0 ,
643643entitydone = 0 ,signdone = 0 ,brackets_ok = 0 ;
644- char temp [fmt_len + 1 ],tmp [2 ]= " " ,lastfmt = ' ' ,fmtchar = ' ' ;
644+ char * temp ;
645+ char tmp [2 ]= " " ;
646+ char lastfmt = ' ' ,fmtchar = ' ' ;
647+
648+ temp = (char * )malloc (fmt_len + 1 );
645649
646- // put all info about the long in a struct
650+ /* put all info about the long in a struct */
647651initValue (lng_val );
648652
649- // '<' is the only format, where we have to align left
653+ /* '<' is the only format, where we have to align left */
650654if (strchr (fmt , (int )'<' )) {
651655leftalign = 1 ;
652656}
653657
654- // '(' requires ')'
658+ /* '(' requires ')' */
655659if (strchr (fmt , (int )'(' )&& strchr (fmt , (int )')' )) {
656660brackets_ok = 1 ;
657661}
658662
659- // get position of the right-most dot in the format-string
660- // and fill the temp-string wit '0's up to there.
663+ /* get position of the right-most dot in the format-string */
664+ /* and fill the temp-string wit '0's up to there. */
661665dotpos = getRightMostDot (fmt );
662666
663- // start to parse the formatstring
667+ /* start to parse the formatstring */
664668temp [0 ]= '\0' ;
665- j = 0 ;// position in temp
666- k = value .digits - 1 ;// position in the value_string
669+ j = 0 ;/* position in temp */
670+ k = value .digits - 1 ;/* position in the value_string */
667671for (i = fmt_len - 1 ,j = 0 ;i >=0 ;i -- ,j ++ ) {
668- // qualify, where we are in the value_string
672+ /* qualify, where we are in the value_string */
669673if (k < 0 ) {
670674if (leftalign ) {
671- // can't use strncat(,,0) here, Solaris would freek out
675+ /* can't use strncat(,,0) here, Solaris would freek out */
672676temp [j ]= '\0' ;
673677break ;
674678}
@@ -680,7 +684,7 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
680684sign = 1 ;
681685}
682686}
683- // if we're right side of the right-most dot, print '0'
687+ /* if we're right side of the right-most dot, print '0' */
684688if (dotpos >=0 && dotpos <=i ) {
685689if (dotpos < i ) {
686690if (fmt [i ]== ')' )tmp [0 ]= value .sign == '-' ?')' :' ' ;
@@ -692,10 +696,10 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
692696strcat (temp ,tmp );
693697continue ;
694698}
695- // the ',' needs special attention, if it is in the blank area
699+ /* the ',' needs special attention, if it is in the blank area */
696700if (blank && fmt [i ]== ',' )fmtchar = lastfmt ;
697701else fmtchar = fmt [i ];
698- // analyse this format-char
702+ /* analyse this format-char */
699703switch (fmtchar ) {
700704case ',' :
701705tmp [0 ]= ',' ;
@@ -755,10 +759,10 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
755759lastfmt = fmt [i ];
756760k -- ;
757761}
758- // safety-net
762+ /* safety-net */
759763temp [fmt_len ]= '\0' ;
760764
761- // reverse the temp-string and put it into the outbuf
765+ /* reverse the temp-string and put it into the outbuf */
762766temp_len = strlen (temp );
763767outbuf [0 ]= '\0' ;
764768for (i = temp_len - 1 ;i >=0 ;i -- ) {
@@ -767,8 +771,8 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
767771}
768772outbuf [temp_len ]= '\0' ;
769773
770- // cleaning up
771- free (tmp );
774+ /* cleaning up */
775+ free (temp );
772776free (value .val_string );
773777
774778return 0 ;