summaryrefslogtreecommitdiffstats
path: root/win/nmakehlp.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/nmakehlp.c')
-rw-r--r--win/nmakehlp.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/win/nmakehlp.c b/win/nmakehlp.c
index 972e8b9..71d727f 100644
--- a/win/nmakehlp.c
+++ b/win/nmakehlp.c
@@ -14,8 +14,10 @@
#define _CRT_SECURE_NO_DEPRECATE
#include <windows.h>
+#ifdef _MSC_VER
#pragma comment (lib, "user32.lib")
#pragma comment (lib, "kernel32.lib")
+#endif
#include <stdio.h>
#include <math.h>
@@ -28,7 +30,7 @@
/* protos */
static int CheckForCompilerFeature(const char *option);
-static int CheckForLinkerFeature(const char **options, int count);
+static int CheckForLinkerFeature(char **options, int count);
static int IsIn(const char *string, const char *substring);
static int SubstituteFile(const char *substs, const char *filename);
static int QualifyPath(const char *path);
@@ -45,8 +47,8 @@ typedef struct {
char buffer[STATICBUFFERSIZE];
} pipeinfo;
-pipeinfo Out = {INVALID_HANDLE_VALUE, '\0'};
-pipeinfo Err = {INVALID_HANDLE_VALUE, '\0'};
+pipeinfo Out = {INVALID_HANDLE_VALUE, ""};
+pipeinfo Err = {INVALID_HANDLE_VALUE, ""};
/*
* exitcodes: 0 == no, 1 == yes, 2 == error
@@ -264,7 +266,7 @@ CheckForCompilerFeature(
"Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
- FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPVOID)&msg[chars],
+ FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPSTR)&msg[chars],
(300-chars), 0);
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, lstrlen(msg), &err,NULL);
return 2;
@@ -317,7 +319,7 @@ CheckForCompilerFeature(
static int
CheckForLinkerFeature(
- const char **options,
+ char **options,
int count)
{
STARTUPINFO si;
@@ -398,7 +400,7 @@ CheckForLinkerFeature(
"Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
- FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPVOID)&msg[chars],
+ FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPSTR)&msg[chars],
(300-chars), 0);
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, lstrlen(msg), &err,NULL);
return 2;
@@ -494,7 +496,6 @@ GetVersionFromFile(
const char *match,
int numdots)
{
- size_t cbBuffer = 100;
static char szBuffer[100];
char *szResult = NULL;
FILE *fp = fopen(filename, "rt");
@@ -504,7 +505,7 @@ GetVersionFromFile(
* Read data until we see our match string.
*/
- while (fgets(szBuffer, cbBuffer, fp) != NULL) {
+ while (fgets(szBuffer, sizeof(szBuffer), fp) != NULL) {
LPSTR p, q;
p = strstr(szBuffer, match);
@@ -514,7 +515,7 @@ GetVersionFromFile(
*/
p += strlen(match);
- while (*p && !isdigit(*p)) {
+ while (*p && !isdigit((unsigned char)*p)) {
++p;
}
@@ -523,14 +524,13 @@ GetVersionFromFile(
*/
q = p;
- while (*q && (strchr("0123456789.ab", *q)) && ((!strchr(".ab", *q)
- && (!strchr("ab", q[-1])) || --numdots))) {
+ while (*q && (strchr("0123456789.ab", *q)) && (((!strchr(".ab", *q)
+ && !strchr("ab", q[-1])) || --numdots))) {
++q;
}
- memcpy(szBuffer, p, q - p);
- szBuffer[q-p] = 0;
- szResult = szBuffer;
+ *q = 0;
+ szResult = p;
break;
}
}
@@ -553,7 +553,7 @@ typedef struct list_item_t {
static list_item_t *
list_insert(list_item_t **listPtrPtr, const char *key, const char *value)
{
- list_item_t *itemPtr = malloc(sizeof(list_item_t));
+ list_item_t *itemPtr = (list_item_t *)malloc(sizeof(list_item_t));
if (itemPtr) {
itemPtr->key = strdup(key);
itemPtr->value = strdup(value);
@@ -602,9 +602,7 @@ SubstituteFile(
const char *substitutions,
const char *filename)
{
- size_t cbBuffer = 1024;
static char szBuffer[1024], szCopy[1024];
- char *szResult = NULL;
list_item_t *substPtr = NULL;
FILE *fp, *sp;
@@ -617,7 +615,7 @@ SubstituteFile(
sp = fopen(substitutions, "rt");
if (sp != NULL) {
- while (fgets(szBuffer, cbBuffer, sp) != NULL) {
+ while (fgets(szBuffer, sizeof(szBuffer), sp) != NULL) {
unsigned char *ks, *ke, *vs, *ve;
ks = (unsigned char*)szBuffer;
while (ks && *ks && isspace(*ks)) ++ks;
@@ -648,7 +646,7 @@ SubstituteFile(
* Run the substitutions over each line of the input
*/
- while (fgets(szBuffer, cbBuffer, fp) != NULL) {
+ while (fgets(szBuffer, sizeof(szBuffer), fp) != NULL) {
list_item_t *p = NULL;
for (p = substPtr; p != NULL; p = p->nextPtr) {
char *m = strstr(szBuffer, p->key);
@@ -665,7 +663,7 @@ SubstituteFile(
memcpy(szBuffer, szCopy, sizeof(szCopy));
}
}
- printf(szBuffer);
+ printf("%s", szBuffer);
}
list_free(&substPtr);
@@ -716,7 +714,8 @@ static int LocateDependencyHelper(const char *dir, const char *keypath)
{
HANDLE hSearch;
char path[MAX_PATH+1];
- int dirlen, keylen, ret;
+ size_t dirlen;
+ int keylen, ret;
WIN32_FIND_DATA finfo;
if (dir == NULL || keypath == NULL)
@@ -783,7 +782,8 @@ static int LocateDependencyHelper(const char *dir, const char *keypath)
*/
static int LocateDependency(const char *keypath)
{
- int i, ret;
+ size_t i;
+ int ret;
static const char *paths[] = {"..", "..\\..", "..\\..\\.."};
for (i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i) {