Formatting and comments added
This commit is contained in:
parent
3a2a05f7b0
commit
7990a82f02
|
|
@ -38,13 +38,13 @@ NON-STANDARD FEATURES
|
||||||
|
|
||||||
============================================================================*/
|
============================================================================*/
|
||||||
|
|
||||||
#include "cmpp.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "cmpp.h"
|
||||||
|
|
||||||
|
|
||||||
/* *********************************************************************** */
|
/* *********************************************************************** */
|
||||||
|
|
@ -52,17 +52,17 @@ NON-STANDARD FEATURES
|
||||||
char *prog_name;
|
char *prog_name;
|
||||||
|
|
||||||
|
|
||||||
/* Initialize print_error() with the name of the program */
|
/* Initialize external variable prog_name with the name of the program.
|
||||||
|
* A copy is not made. */
|
||||||
void init_error(char *program_name)
|
void init_error(char *program_name)
|
||||||
{
|
{
|
||||||
prog_name = program_name;
|
prog_name = program_name;
|
||||||
}
|
} /* end of function init_error */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Print an error message to stderr */
|
/* Print an error message to stderr. The message is prefixed with the
|
||||||
|
* name of the program and a newline character is added to the end. */
|
||||||
void print_error(const char *fmt, ...)
|
void print_error(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
@ -73,22 +73,25 @@ void print_error(const char *fmt, ...)
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
} /* end of function print_error */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Convert a string to all lower case */
|
/* Convert a string to all lower case */
|
||||||
|
|
||||||
void str_to_lower(char *s)
|
void str_to_lower(char *s)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
for(i = 0; (c = s[i]) != '\0'; i++)
|
for(i = 0; (c = s[i]) != '\0'; i++) {
|
||||||
s[i] = tolower_c(c);
|
s[i] = tolower_c(c);
|
||||||
}
|
}
|
||||||
|
} /* end of function str_to_lower */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* If *path_p is relative, prefix with the CMPP output or input string
|
||||||
|
* build the path and open the file and return the path that was created. */
|
||||||
FILE *fopen_cmpp(const char **path_p, const char *mode)
|
FILE *fopen_cmpp(const char **path_p, const char *mode)
|
||||||
{
|
{
|
||||||
const char *path = *path_p;
|
const char *path = *path_p;
|
||||||
|
|
@ -103,7 +106,8 @@ FILE *fopen_cmpp(const char **path_p, const char *mode)
|
||||||
strcat(buf, "/");
|
strcat(buf, "/");
|
||||||
strcat(buf, path);
|
strcat(buf, path);
|
||||||
path = buf;
|
path = buf;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
path = NULL;
|
path = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -112,4 +116,7 @@ FILE *fopen_cmpp(const char **path_p, const char *mode)
|
||||||
*path_p = strdup(path);
|
*path_p = strdup(path);
|
||||||
|
|
||||||
return fopen(path, mode);
|
return fopen(path, mode);
|
||||||
}
|
} /* end of function fopen_cmpp */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue