From 5079d2ee7d24227ac6c15750faab05e9428e0a81 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Sat, 11 Sep 2004 09:24:55 +0000 Subject: [PATCH] truncsp() and truncnl() are now part of genwrap.c (since STRERROR needs truncsp() on Win32 anyway). --- src/xpdev/dat_file.c | 2 -- src/xpdev/genwrap.c | 28 ++++++++++++++++++++++++++++ src/xpdev/genwrap.h | 5 +++++ src/xpdev/ini_file.c | 2 -- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/xpdev/dat_file.c b/src/xpdev/dat_file.c index 0271fb088c..418f3ff95f 100644 --- a/src/xpdev/dat_file.c +++ b/src/xpdev/dat_file.c @@ -41,8 +41,6 @@ #include <stdlib.h> /* malloc */ #include <string.h> /* strdup */ -#include "truncsp.c" /* truncsp() and truncnl() */ - /***********************************/ /* CSV (Comma Separated Value) API */ /***********************************/ diff --git a/src/xpdev/genwrap.c b/src/xpdev/genwrap.c index 1299e8ee27..c71a623284 100644 --- a/src/xpdev/genwrap.c +++ b/src/xpdev/genwrap.c @@ -416,3 +416,31 @@ clock_t DLLCALL msclock(void) return((clock_t)(usecs/(1000000/MSCLOCKS_PER_SEC))); } #endif + +/****************************************************************************/ +/* Truncates all white-space chars off end of 'str' (needed by STRERRROR) */ +/****************************************************************************/ +char* DLLCALL truncsp(char* str) +{ + unsigned c; + + c=strlen(str); + while(c && (str[c-1]==' ' || str[c-1]=='\t' || str[c-1]=='\r' || str[c-1]=='\n')) c--; + str[c]=0; + + return(str); +} + +/****************************************************************************/ +/* Truncates carriage-return and line-feed chars off end of 'str' */ +/****************************************************************************/ +char* DLLCALL truncnl(char* str) +{ + unsigned c; + + c=strlen(str); + while(c && (str[c-1]=='\r' || str[c-1]=='\n')) c--; + str[c]=0; + + return(str); +} diff --git a/src/xpdev/genwrap.h b/src/xpdev/genwrap.h index 31ce7a1ed1..dcf372a461 100644 --- a/src/xpdev/genwrap.h +++ b/src/xpdev/genwrap.h @@ -171,6 +171,11 @@ extern "C" { #endif #endif +/* Truncate white-space chars off end of string */ +DLLEXPORT char* DLLCALL truncsp(char* str); +/* Truncate new-line chars off end of string */ +DLLEXPORT char* DLLCALL truncnl(char* str); + #if defined(__unix__) #define STRERROR(x) strerror(x) #else diff --git a/src/xpdev/ini_file.c b/src/xpdev/ini_file.c index 465fd16f56..0ea9e8ac02 100644 --- a/src/xpdev/ini_file.c +++ b/src/xpdev/ini_file.c @@ -54,8 +54,6 @@ static ini_style_t default_style; -#include "truncsp.c" /* truncsp() and truncnl() */ - static char* section_name(char* p) { char* tp; -- GitLab