MCPcopy Create free account
hub / github.com/Singular/Singular / feCleanUpFile

Function feCleanUpFile

resources/feResource.cc:469–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

467}
468
469static char* feCleanUpFile(char* fname)
470{
471 char* fn;
472
473#ifdef RESOURCE_DEBUG
474 printf("feCleanUpFile: entering with =%s=\n", fname);
475#endif
476 // Remove unnecessary .. and //
477 for (fn = fname; *fn != '\0'; fn++)
478 {
479 if (*fn == '/')
480 {
481 if (*(fn+1) == '\0')
482 {
483 if (fname != fn) *fn = '\0';
484 break;
485 }
486 if (*(fn + 1) == '/' && (fname != fn))
487 {
488 mystrcpy(fn, fn+1);
489 fn--;
490 }
491 else if (*(fn+1) == '.')
492 {
493 if (*(fn+2) == '.' && (*(fn + 3) == '/' || *(fn + 3) == '\0'))
494 {
495 #if 0
496 // this does not work: ./../../mmm will be changed to ./../mmm
497 // but we only want to change ././mmm to ./mmm
498 *fn = '\0';
499 s = strrchr(fname, '/');
500 if (s != NULL)
501 {
502 mystrcpy(s+1, fn + (*(fn + 3) != '\0' ? 4 : 3));
503 fn = s-1;
504 }
505 else
506 {
507 *fn = '/';
508 }
509 #endif
510 }
511 else if (*(fn+2) == '/' || *(fn+2) == '\0')
512 {
513 mystrcpy(fn+1, fn+3);
514 fn--;
515 }
516 }
517 }
518 }
519
520#ifdef RESOURCE_DEBUG
521 printf("feCleanUpFile: leaving with =%s=\n", fname);
522#endif
523 return fname;
524}
525
526// remove duplicates dir resp. those which do not exist

Callers 2

feCleanResourceValueFunction · 0.85
feCleanUpPathFunction · 0.85

Calls 1

mystrcpyFunction · 0.85

Tested by

no test coverage detected