Skip to content

Commit a8f968f

Browse files
committed
Replaces ConcDirAndName and ConcNameAndVersion macros with static inline procedures.
These are used in many places so code bloat can be reduced by using procedures.
1 parent 5060cae commit a8f968f

File tree

1 file changed

+54
-53
lines changed

1 file changed

+54
-53
lines changed

inc/locfile.h

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ do { \
296296
goto truetag; /* NOLINT(bugprone-macro-parentheses) */ \
297297
} while (0)
298298

299-
/*
299+
/*
300300
* Name: LispVersionToUnixVersion
301301
*
302302
* Argument: char *pathname
@@ -331,7 +331,7 @@ do { \
331331
#endif /* DOS */
332332

333333

334-
/*
334+
/*
335335
* Name: UnixVersionToLispVersion
336336
*
337337
* Argument: char *pathname UNIX syntax pathname.
@@ -349,7 +349,7 @@ do { \
349349
* version field will append a semicolon and it might make the routine be
350350
* confused.
351351
* The file which has not a valid version field, that is ".~##~" form, is
352-
* dealt with as version 1.
352+
* dealt with as version 1.
353353
*/
354354

355355
#define UnixVersionToLispVersion(pathname, vlessp) \
@@ -367,7 +367,7 @@ do { \
367367
} \
368368
} while (0)
369369

370-
/*
370+
/*
371371
* Name: ConcDirAndName
372372
*
373373
* Argument: char *dir The name of the directory.
@@ -385,45 +385,45 @@ do { \
385385
*
386386
*/
387387

388-
#define ConcDirAndName(dir, name, fname) do { \
389-
\
390-
char *lf_cp1, *lf_cp2; \
391-
\
392-
lf_cp1 = dir; \
393-
lf_cp2 = dir; \
394-
\
395-
while (*lf_cp2 != '\0') { \
396-
switch (*lf_cp2) { \
397-
\
398-
case '/': \
399-
lf_cp1 = lf_cp2; \
400-
lf_cp2++; \
401-
break; \
402-
\
403-
default: \
404-
lf_cp2++; \
405-
break; \
406-
} \
407-
} \
408-
if (lf_cp1 == (lf_cp2 - 1)) { \
409-
if (lf_cp1 == (dir)) { \
410-
/* dir is a root directory. */ \
411-
strcpy(fname, "/"); \
412-
strcat(fname, name); \
413-
} else { \
414-
/* The trail directory is included. */ \
415-
strcpy(fname, dir); \
416-
strcat(fname, name); \
417-
} \
418-
} else { \
419-
/* The trail directory is not included */ \
420-
strcpy(fname, dir); \
421-
strcat(fname, "/"); \
422-
strcat(fname, name); \
423-
} \
424-
} while (0)
388+
static inline void ConcDirAndName(char *dir, char *name, char *fname)
389+
{
390+
char *lf_cp1, *lf_cp2;
391+
392+
lf_cp1 = dir;
393+
lf_cp2 = dir;
425394

426-
/*
395+
while (*lf_cp2 != '\0') {
396+
switch (*lf_cp2) {
397+
398+
case '/':
399+
lf_cp1 = lf_cp2;
400+
lf_cp2++;
401+
break;
402+
403+
default:
404+
lf_cp2++;
405+
break;
406+
}
407+
}
408+
if (lf_cp1 == (lf_cp2 - 1)) {
409+
if (lf_cp1 == (dir)) {
410+
/* dir is a root directory. */
411+
strcpy(fname, "/");
412+
strcat(fname, name);
413+
} else {
414+
/* The trail directory is included. */
415+
strcpy(fname, dir);
416+
strcat(fname, name);
417+
}
418+
} else {
419+
/* The trail directory is not included */
420+
strcpy(fname, dir);
421+
strcat(fname, "/");
422+
strcat(fname, name);
423+
}
424+
}
425+
426+
/*
427427
* Name: ConcNameAndVersion
428428
*
429429
* Argument: char *name The root file name.
@@ -443,16 +443,17 @@ do { \
443443
*
444444
*/
445445

446-
#define ConcNameAndVersion(name, ver, rname) do { \
447-
if (*(ver) != '\0') { \
448-
strcpy(rname, name); \
449-
strcat(rname, ".~"); \
450-
strcat(rname, ver); \
451-
strcat(rname, "~"); \
452-
} else { \
453-
strcpy(rname, name); \
454-
} \
455-
} while (0)
446+
static inline void ConcNameAndVersion(char *name, char *ver, char *rname)
447+
{
448+
if (*ver != '\0') {
449+
strcpy(rname, name);
450+
strcat(rname, ".~");
451+
strcat(rname, ver);
452+
strcat(rname, "~");
453+
} else {
454+
strcpy(rname, name);
455+
}
456+
}
456457

457458
#define VERSIONLEN 10
458459

@@ -502,7 +503,7 @@ do { \
502503
*(lf_cp-1) = '\0'; \
503504
} \
504505
} while (0)
505-
506+
506507
#define ChangeToVersionless(pathname) do { \
507508
char *lf_cp; \
508509
if( (lf_cp=strrchr(pathname, ';')) != 0) \

0 commit comments

Comments
 (0)