- Timestamp:
- Sep 19, 2014, 4:05:27 PM (12 years ago)
- Location:
- branches/eam_branches/ps2-tc3-20130727
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ps2-tc3-20130727
- Property svn:mergeinfo changed
-
branches/eam_branches/ps2-tc3-20130727/Ohana
- Property svn:mergeinfo changed
-
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/lib.shell/string.c
r33662 r37403 322 322 } 323 323 324 int set_list_varname (char *line, char *base, int N, int excelStyle) { 325 326 int i; 327 328 // A-Z correspond to 0 - 25 329 330 if (excelStyle) { 331 float f = log(26.0); 332 float g = (N == 0) ? 0.0 : log(1.0*N); 333 int Ndigit = (int) (g / f) + 1; 334 if (Ndigit > 10) { 335 sprintf (line, "%s:ZZZZZZZZZZ", base); 336 return FALSE; 337 } 338 char name[12]; 339 memset (name, 0, 12); 340 for (i = 0; i < Ndigit; i++) { 341 float Npow = Ndigit - i - 1; 342 float g = pow(26.0, Npow); 343 int V = (int) (N / g); 344 name[i] = (Npow == 0.0) ? 'A' + V : 'A' + V - 1; 345 N -= V * g; 346 } 347 sprintf (line, "%s:%s", base, name); 348 } else { 349 sprintf (line, "%s:%d", base, N); 350 } 351 return TRUE; 352 }
Note:
See TracChangeset
for help on using the changeset viewer.
