include strlcpy and *printf and use them
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14930 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -2,6 +2,12 @@
|
||||
|
||||
include $(top_srcdir)/Makefile.am.common
|
||||
|
||||
if do_roken_rename
|
||||
ES = snprintf.c strlcpy.c
|
||||
endif
|
||||
|
||||
AM_CPPFLAGS += $(ROKEN_RENAME)
|
||||
|
||||
YFLAGS = -d
|
||||
|
||||
lib_LTLIBRARIES = libcom_err.la
|
||||
@@ -13,7 +19,7 @@ include_HEADERS = com_err.h com_right.h
|
||||
|
||||
compile_et_SOURCES = compile_et.c compile_et.h parse.y lex.l
|
||||
|
||||
libcom_err_la_SOURCES = error.c com_err.c roken_rename.h
|
||||
libcom_err_la_SOURCES = error.c com_err.c roken_rename.h $(ES)
|
||||
|
||||
CLEANFILES = lex.c parse.c parse.h
|
||||
|
||||
@@ -22,3 +28,8 @@ $(compile_et_OBJECTS): parse.h parse.c ## XXX broken automake 1.4s
|
||||
compile_et_LDADD = \
|
||||
$(LIB_roken) \
|
||||
$(LEXLIB)
|
||||
|
||||
snprintf.c:
|
||||
$(LN_S) $(srcdir)/../roken/snprintf.c .
|
||||
strlcpy.c:
|
||||
$(LN_S) $(srcdir)/../roken/strlcpy.c .
|
||||
|
@@ -51,15 +51,14 @@ error_message (long code)
|
||||
const char *p = com_right(_et_list, code);
|
||||
if (p == NULL) {
|
||||
if (code < 0)
|
||||
sprintf(msg, "Unknown error %ld", code);
|
||||
snprintf(msg, sizeof(msg), "Unknown error %ld", code);
|
||||
else
|
||||
p = strerror(code);
|
||||
}
|
||||
if (p != NULL && *p != '\0') {
|
||||
strncpy(msg, p, sizeof(msg) - 1);
|
||||
msg[sizeof(msg) - 1] = 0;
|
||||
strlcpy(msg, p, sizeof(msg));
|
||||
} else
|
||||
sprintf(msg, "Unknown error %ld", code);
|
||||
snprintf(msg, sizeof(msg), "Unknown error %ld", code);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
@@ -102,9 +102,8 @@ statement : INDEX NUMBER
|
||||
}
|
||||
| PREFIX STRING
|
||||
{
|
||||
prefix = realloc(prefix, strlen($2) + 2);
|
||||
strcpy(prefix, $2);
|
||||
strcat(prefix, "_");
|
||||
free(prefix);
|
||||
asprintf (&prefix, "%s_", $2);
|
||||
free($2);
|
||||
}
|
||||
| PREFIX
|
||||
|
@@ -36,4 +36,27 @@
|
||||
#ifndef __roken_rename_h__
|
||||
#define __roken_rename_h__
|
||||
|
||||
#ifndef HAVE_SNPRINTF
|
||||
#define snprintf _com_err_snprintf
|
||||
#endif
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
#define vsnprintf _com_err_vsnprintf
|
||||
#endif
|
||||
#ifndef HAVE_ASPRINTF
|
||||
#define asprintf _com_err_asprintf
|
||||
#endif
|
||||
#ifndef HAVE_ASNPRINTF
|
||||
#define asnprintf _com_err_asnprintf
|
||||
#endif
|
||||
#ifndef HAVE_VASPRINTF
|
||||
#define vasprintf _com_err_vasprintf
|
||||
#endif
|
||||
#ifndef HAVE_VASNPRINTF
|
||||
#define vasnprintf _com_err_vasnprintf
|
||||
#endif
|
||||
#ifndef HAVE_STRLCPY
|
||||
#define strlcpy _com_err_strlcpy
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __roken_rename_h__ */
|
||||
|
Reference in New Issue
Block a user