Skip to content

Commit 752951c

Browse files
committed
Updated copyright message using compilation date instead of hardcoded year.
1 parent f03eecf commit 752951c

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/bin2cpp.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "md5Ex.h"
88
#include "..\version_info.h"
99

10+
extern int getCopyrightYear();
11+
1012
namespace bin2cpp
1113
{
1214
std::string gHexSymbols[256];
@@ -308,7 +310,7 @@ namespace bin2cpp
308310

309311
fprintf(header, "/**\n");
310312
fprintf(header, " * This file was generated by bin2cpp v%s.\n", getVersionString() );
311-
fprintf(header, " * Copyright (C) 2013-2017 end2endzone.com. All rights reserved.\n");
313+
fprintf(header, " * Copyright (C) 2013-%d end2endzone.com. All rights reserved.\n", ::getCopyrightYear());
312314
fprintf(header, " * Do not modify this file.\n");
313315
fprintf(header, " */\n");
314316
fprintf(header, "#pragma once\n");
@@ -409,7 +411,7 @@ namespace bin2cpp
409411
//write cpp file heading
410412
fprintf(cpp, "/**\n");
411413
fprintf(cpp, " * This file was generated by bin2cpp v%s.\n", getVersionString() );
412-
fprintf(cpp, " * Copyright (C) 2013-2014 end2endzone.com. All rights reserved.\n");
414+
fprintf(cpp, " * Copyright (C) 2013-%d end2endzone.com. All rights reserved.\n", ::getCopyrightYear());
413415
fprintf(cpp, " * Do not modify this file.\n");
414416
fprintf(cpp, " */\n");
415417
fprintf(cpp, "#include \"%s\"\n", headerPath.c_str() );

src/main.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,25 @@
1515
#include <windows.h>
1616
#endif
1717

18+
int getCopyrightYear()
19+
{
20+
static const int DEFAULT_YEAR = 2016;
21+
std::string compilationDate = __DATE__;
22+
size_t space1Pos = compilationDate.find(" ", 0);
23+
if (space1Pos == std::string::npos)
24+
return DEFAULT_YEAR;
25+
size_t space2Pos = compilationDate.find(" ", space1Pos+1);
26+
if (space2Pos == std::string::npos)
27+
return DEFAULT_YEAR;
28+
const char * yearStr = &compilationDate[space2Pos+1];
29+
int year = atoi(yearStr);
30+
return year;
31+
}
32+
1833
void printHeader()
1934
{
2035
printf("bin2cpp v%s\n", bin2cpp::getVersionString() );
21-
printf("Copyright (C) 2013-2017 end2endzone.com. All rights reserved.\n");
36+
printf("Copyright (C) 2013-%d end2endzone.com. All rights reserved.\n", getCopyrightYear());
2237
}
2338

2439
void printUsage()

0 commit comments

Comments
 (0)