X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Funits.C;h=9c2f1d27106b7f4be2cee7ec37f70c5bd91edf04;hb=efb3600851fd27b13d3053ffbdb6434535580bfd;hp=8e24d3efaed6c8b6bbe9325e9b9f1d80d364f916;hpb=7b05ad287956f8bd00836d9b5fb39f899a5fb641;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/guicast/units.C b/cinelerra-5.1/guicast/units.C index 8e24d3ef..9c2f1d27 100644 --- a/cinelerra-5.1/guicast/units.C +++ b/cinelerra-5.1/guicast/units.C @@ -620,14 +620,13 @@ const char* Units::format_to_separators(int time_format) void Units::punctuate(char *string) { - int len = strlen(string); - int commas = (len - 1) / 3; - for(int i = len + commas, j = len, k; j >= 0 && i >= 0; i--, j--) { - k = (len - j - 1) / 3; - if(k * 3 == len - j - 1 && j != len - 1 && string[j] != 0) { - string[i--] = ','; - } - string[i] = string[j]; + int sep = ',', len = strlen(string), commas = (len - 1) / 3; + char *cp = string + len, *bp = cp + commas; + *bp = 0; + for( int k=3; cp < bp && bp > string; ) { + *--bp = *--cp; + if( --k > 0 ) continue; + *--bp = sep; k = 3; } }