Skip to content

Commit eb78e23

Browse files
bmwillgitster
authored andcommitted
wrapper: rename 'template' variables
Rename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler. Signed-off-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 38f3f09 commit eb78e23

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

git-compat-util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,8 +826,8 @@ extern ssize_t xpread(int fd, void *buf, size_t len, off_t offset);
826826
extern int xdup(int fd);
827827
extern FILE *xfopen(const char *path, const char *mode);
828828
extern FILE *xfdopen(int fd, const char *mode);
829-
extern int xmkstemp(char *template);
830-
extern int xmkstemp_mode(char *template, int mode);
829+
extern int xmkstemp(char *temp_filename);
830+
extern int xmkstemp_mode(char *temp_filename, int mode);
831831
extern char *xgetcwd(void);
832832
extern FILE *fopen_for_writing(const char *path);
833833
extern FILE *fopen_or_warn(const char *path, const char *mode);

wrapper.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -445,21 +445,21 @@ FILE *fopen_or_warn(const char *path, const char *mode)
445445
return NULL;
446446
}
447447

448-
int xmkstemp(char *template)
448+
int xmkstemp(char *filename_template)
449449
{
450450
int fd;
451451
char origtemplate[PATH_MAX];
452-
strlcpy(origtemplate, template, sizeof(origtemplate));
452+
strlcpy(origtemplate, filename_template, sizeof(origtemplate));
453453

454-
fd = mkstemp(template);
454+
fd = mkstemp(filename_template);
455455
if (fd < 0) {
456456
int saved_errno = errno;
457457
const char *nonrelative_template;
458458

459-
if (strlen(template) != strlen(origtemplate))
460-
template = origtemplate;
459+
if (strlen(filename_template) != strlen(origtemplate))
460+
filename_template = origtemplate;
461461

462-
nonrelative_template = absolute_path(template);
462+
nonrelative_template = absolute_path(filename_template);
463463
errno = saved_errno;
464464
die_errno("Unable to create temporary file '%s'",
465465
nonrelative_template);
@@ -481,7 +481,7 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
481481
static const int num_letters = 62;
482482
uint64_t value;
483483
struct timeval tv;
484-
char *template;
484+
char *filename_template;
485485
size_t len;
486486
int fd, count;
487487

@@ -503,16 +503,16 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
503503
*/
504504
gettimeofday(&tv, NULL);
505505
value = ((size_t)(tv.tv_usec << 16)) ^ tv.tv_sec ^ getpid();
506-
template = &pattern[len - 6 - suffix_len];
506+
filename_template = &pattern[len - 6 - suffix_len];
507507
for (count = 0; count < TMP_MAX; ++count) {
508508
uint64_t v = value;
509509
/* Fill in the random bits. */
510-
template[0] = letters[v % num_letters]; v /= num_letters;
511-
template[1] = letters[v % num_letters]; v /= num_letters;
512-
template[2] = letters[v % num_letters]; v /= num_letters;
513-
template[3] = letters[v % num_letters]; v /= num_letters;
514-
template[4] = letters[v % num_letters]; v /= num_letters;
515-
template[5] = letters[v % num_letters]; v /= num_letters;
510+
filename_template[0] = letters[v % num_letters]; v /= num_letters;
511+
filename_template[1] = letters[v % num_letters]; v /= num_letters;
512+
filename_template[2] = letters[v % num_letters]; v /= num_letters;
513+
filename_template[3] = letters[v % num_letters]; v /= num_letters;
514+
filename_template[4] = letters[v % num_letters]; v /= num_letters;
515+
filename_template[5] = letters[v % num_letters]; v /= num_letters;
516516

517517
fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode);
518518
if (fd >= 0)
@@ -541,21 +541,21 @@ int git_mkstemp_mode(char *pattern, int mode)
541541
return git_mkstemps_mode(pattern, 0, mode);
542542
}
543543

544-
int xmkstemp_mode(char *template, int mode)
544+
int xmkstemp_mode(char *filename_template, int mode)
545545
{
546546
int fd;
547547
char origtemplate[PATH_MAX];
548-
strlcpy(origtemplate, template, sizeof(origtemplate));
548+
strlcpy(origtemplate, filename_template, sizeof(origtemplate));
549549

550-
fd = git_mkstemp_mode(template, mode);
550+
fd = git_mkstemp_mode(filename_template, mode);
551551
if (fd < 0) {
552552
int saved_errno = errno;
553553
const char *nonrelative_template;
554554

555-
if (!template[0])
556-
template = origtemplate;
555+
if (!filename_template[0])
556+
filename_template = origtemplate;
557557

558-
nonrelative_template = absolute_path(template);
558+
nonrelative_template = absolute_path(filename_template);
559559
errno = saved_errno;
560560
die_errno("Unable to create temporary file '%s'",
561561
nonrelative_template);

0 commit comments

Comments
 (0)