[Freeciv-Dev] patch: move my* funcs to common/support (PR#214)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
This fairly straightforward patch moves mystrcasecmp(),
mystrncasecmp(), mystrerror() and myusleep() from shared.c
to support.c.
-- David
diff -u -r --exclude-from exclude fc-adv/client/clinet.c
freeciv-mod/client/clinet.c
--- fc-adv/client/clinet.c Mon Oct 4 18:40:04 1999
+++ freeciv-mod/client/clinet.c Wed Dec 29 11:28:49 1999
@@ -64,6 +64,7 @@
#include "log.h"
#include "mem.h"
#include "packets.h"
+#include "support.h"
#include "version.h"
#include "chatline_g.h"
diff -u -r --exclude-from exclude fc-adv/client/gui-gtk/mapview.c
freeciv-mod/client/gui-gtk/mapview.c
--- fc-adv/client/gui-gtk/mapview.c Tue Dec 28 18:38:15 1999
+++ freeciv-mod/client/gui-gtk/mapview.c Wed Dec 29 11:29:45 1999
@@ -29,7 +29,7 @@
#include "government.h" /* government_graphic() */
#include "map.h"
#include "player.h"
-#include "shared.h" /* myusleep() */
+#include "support.h" /* myusleep() */
#include "civclient.h"
#include "colors.h"
diff -u -r --exclude-from exclude fc-adv/client/gui-mui/mapview.c
freeciv-mod/client/gui-mui/mapview.c
--- fc-adv/client/gui-mui/mapview.c Tue Dec 28 22:07:12 1999
+++ freeciv-mod/client/gui-mui/mapview.c Wed Dec 29 11:30:51 1999
@@ -27,6 +27,7 @@
#include "government.h" /* government_graphic() */
#include "map.h"
#include "player.h"
+#include "support.h" /* myusleep() */
#include "control.h"
#include "graphics.h"
diff -u -r --exclude-from exclude fc-adv/client/gui-xaw/mapview.c
freeciv-mod/client/gui-xaw/mapview.c
--- fc-adv/client/gui-xaw/mapview.c Tue Dec 28 18:38:18 1999
+++ freeciv-mod/client/gui-xaw/mapview.c Wed Dec 29 11:29:20 1999
@@ -29,7 +29,7 @@
#include "government.h" /* government_graphic() */
#include "map.h"
#include "player.h"
-#include "shared.h" /* myusleep() */
+#include "support.h" /* myusleep() */
#include "unit.h"
#include "civclient.h"
diff -u -r --exclude-from exclude fc-adv/common/city.c freeciv-mod/common/city.c
--- fc-adv/common/city.c Tue Dec 28 18:38:20 1999
+++ freeciv-mod/common/city.c Wed Dec 29 11:24:31 1999
@@ -25,6 +25,7 @@
#include "map.h"
#include "mem.h"
#include "shared.h"
+#include "support.h"
#include "tech.h"
#include "city.h"
diff -u -r --exclude-from exclude fc-adv/common/government.c
freeciv-mod/common/government.c
--- fc-adv/common/government.c Tue Dec 28 00:54:36 1999
+++ freeciv-mod/common/government.c Wed Dec 29 11:24:38 1999
@@ -19,6 +19,7 @@
#include "mem.h"
#include "player.h"
#include "shared.h"
+#include "support.h"
#include "tech.h"
#include "government.h"
diff -u -r --exclude-from exclude fc-adv/common/nation.c
freeciv-mod/common/nation.c
--- fc-adv/common/nation.c Sat Oct 2 15:07:23 1999
+++ freeciv-mod/common/nation.c Wed Dec 29 11:24:47 1999
@@ -24,6 +24,7 @@
#include "log.h"
#include "mem.h"
#include "player.h"
+#include "support.h"
#include "tech.h"
#include "nation.h"
diff -u -r --exclude-from exclude fc-adv/common/player.c
freeciv-mod/common/player.c
--- fc-adv/common/player.c Wed Dec 29 11:14:34 1999
+++ freeciv-mod/common/player.c Wed Dec 29 11:24:52 1999
@@ -20,6 +20,7 @@
#include "map.h"
#include "rand.h"
#include "shared.h"
+#include "support.h"
#include "tech.h"
#include "unit.h"
diff -u -r --exclude-from exclude fc-adv/common/shared.c
freeciv-mod/common/shared.c
--- fc-adv/common/shared.c Wed Dec 29 11:14:34 1999
+++ freeciv-mod/common/shared.c Wed Dec 29 11:20:18 1999
@@ -27,20 +27,6 @@
#include <pwd.h>
#endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-
-#ifdef GENERATING_MAC
-#include <events.h> /* for WaitNextEvent() */
-#endif
-
#include "fcintl.h"
#include "log.h"
#include "mem.h"
@@ -247,34 +233,6 @@
return y;
}
-
-/***************************************************************
- Compare strings like strcmp(), but ignoring case.
-***************************************************************/
-int mystrcasecmp(const char *str0, const char *str1)
-{
- for(; tolower(*str0)==tolower(*str1); str0++, str1++)
- if(*str0=='\0')
- return 0;
-
- return tolower(*str0)-tolower(*str1);
-}
-
-/***************************************************************
- Compare strings like strncmp(), but ignoring case.
- ie, only compares first n chars.
-***************************************************************/
-int mystrncasecmp(const char *str0, const char *str1, size_t n)
-{
- size_t i;
-
- for(i=0; i<n && tolower(*str0)==tolower(*str1); i++, str0++, str1++)
- if(*str0=='\0')
- return 0;
-
- return (i==n) ? 0 : (tolower(*str0)-tolower(*str1));
-}
-
/**************************************************************************
string_ptr_compare() - fiddles with pointers to do a simple string compare
when passed pointers to two strings -- called from
@@ -284,47 +242,6 @@
int string_ptr_compare(const void *first, const void *second)
{
return mystrcasecmp(*((const char **)first), *((const char **)second));
-}
-
-/***************************************************************
-...
-***************************************************************/
-char *mystrerror(int errnum)
-{
-#if defined(HAVE_STRERROR) || !defined(HAVE_CONFIG_H)
- /* if we have real strerror() or if we're not using configure */
- return strerror(errnum);
-#else
- static char buf[64];
- sprintf(buf, _("error %d (compiled without strerror)"), errnum);
- return buf;
-#endif
-}
-
-/***************************************************************
-...
-***************************************************************/
-void myusleep(unsigned long usec)
-{
-#ifdef HAVE_USLEEP
- usleep(usec);
-#else
-#ifdef HAVE_SNOOZE /* BeOS */
- snooze(usec);
-#else
-#ifdef GENERATING_MAC
- EventRecord the_event; /* dummy var for timesharing */
- WaitNextEvent(0, &the_event, GetCaretTime(), nil); /* this is suposed to
- give other application procseor time for the mac*/
-#else
- struct timeval tv;
-
- tv.tv_sec=0;
- tv.tv_usec=100;
- select(0, NULL, NULL, NULL, &tv);
-#endif
-#endif
-#endif
}
/***************************************************************************
diff -u -r --exclude-from exclude fc-adv/common/shared.h
freeciv-mod/common/shared.h
--- fc-adv/common/shared.h Wed Dec 29 11:14:34 1999
+++ freeciv-mod/common/shared.h Wed Dec 29 11:16:11 1999
@@ -58,12 +58,7 @@
char *int_to_text(int nr);
char *get_sane_name(char *name);
char *textyear(int year);
-int mystrcasecmp(const char *str0, const char *str1);
-int mystrncasecmp(const char *str0, const char *str1, size_t n);
int string_ptr_compare(const void *first, const void *second);
-
-char *mystrerror(int errnum);
-void myusleep(unsigned long usec);
char *skip_leading_spaces(char *s);
void remove_trailing_spaces(char *s);
diff -u -r --exclude-from exclude fc-adv/common/support.c
freeciv-mod/common/support.c
--- fc-adv/common/support.c Wed Dec 29 10:47:27 1999
+++ freeciv-mod/common/support.c Wed Dec 29 11:24:12 1999
@@ -46,10 +46,100 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h> /* usleep */
+#endif
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+
+#ifdef GENERATING_MAC
+#include <events.h> /* for WaitNextEvent() */
+#endif
+
+#include "fcintl.h"
#include "mem.h"
#include "support.h"
+
+/***************************************************************
+ Compare strings like strcmp(), but ignoring case.
+***************************************************************/
+int mystrcasecmp(const char *str0, const char *str1)
+{
+ for(; tolower(*str0)==tolower(*str1); str0++, str1++)
+ if(*str0=='\0')
+ return 0;
+
+ return tolower(*str0)-tolower(*str1);
+}
+
+/***************************************************************
+ Compare strings like strncmp(), but ignoring case.
+ ie, only compares first n chars.
+***************************************************************/
+int mystrncasecmp(const char *str0, const char *str1, size_t n)
+{
+ size_t i;
+
+ for(i=0; i<n && tolower(*str0)==tolower(*str1); i++, str0++, str1++)
+ if(*str0=='\0')
+ return 0;
+
+ return (i==n) ? 0 : (tolower(*str0)-tolower(*str1));
+}
+
+
+/***************************************************************
+...
+***************************************************************/
+char *mystrerror(int errnum)
+{
+#if defined(HAVE_STRERROR)
+ return strerror(errnum);
+#else
+ static char buf[64];
+ sprintf(buf, _("error %d (compiled without strerror)"), errnum);
+ return buf;
+#endif
+}
+
+
+/***************************************************************
+...
+***************************************************************/
+void myusleep(unsigned long usec)
+{
+#ifdef HAVE_USLEEP
+ usleep(usec);
+#else
+#ifdef HAVE_SNOOZE /* BeOS */
+ snooze(usec);
+#else
+#ifdef GENERATING_MAC
+ EventRecord the_event; /* dummy var for timesharing */
+ WaitNextEvent(0, &the_event, GetCaretTime(), nil); /* this is suposed to
+ give other application processor time for the mac */
+#else
+ struct timeval tv;
+
+ tv.tv_sec=0;
+ tv.tv_usec=100;
+ select(0, NULL, NULL, NULL, &tv);
+#endif
+#endif
+#endif
+}
+
/**********************************************************************
mystrlcpy() and mystrlcat() provide (non-standard) functions
diff -u -r --exclude-from exclude fc-adv/common/support.h
freeciv-mod/common/support.h
--- fc-adv/common/support.h Wed Dec 29 10:47:27 1999
+++ freeciv-mod/common/support.h Wed Dec 29 11:27:01 1999
@@ -17,15 +17,19 @@
/**********************************************************************
Replacements for functions which are not available on all platforms.
Where the functions are available natively, these are just wrappers.
- See also some functions in shared.h (some of which should be moved
- here), and functions/macros in mem.h. See support.c for more
- comments.
+ See also mem.h, rand.h, and see support.c for more comments.
***********************************************************************/
#include <stdlib.h> /* size_t */
#include <stdarg.h>
#include "attribute.h"
+
+int mystrcasecmp(const char *str0, const char *str1);
+int mystrncasecmp(const char *str0, const char *str1, size_t n);
+
+char *mystrerror(int errnum);
+void myusleep(unsigned long usec);
size_t mystrlcpy(char *dest, const char *src, size_t n);
size_t mystrlcat(char *dest, const char *src, size_t n);
diff -u -r --exclude-from exclude fc-adv/common/tech.c freeciv-mod/common/tech.c
--- fc-adv/common/tech.c Thu Dec 23 16:54:57 1999
+++ freeciv-mod/common/tech.c Wed Dec 29 11:24:58 1999
@@ -17,6 +17,7 @@
#include "game.h"
#include "player.h"
+#include "support.h"
#include "tech.h"
diff -u -r --exclude-from exclude fc-adv/common/unit.c freeciv-mod/common/unit.c
--- fc-adv/common/unit.c Tue Dec 28 22:07:14 1999
+++ freeciv-mod/common/unit.c Wed Dec 29 11:25:09 1999
@@ -27,6 +27,7 @@
#include "map.h"
#include "mem.h"
#include "player.h"
+#include "support.h"
#include "tech.h"
#include "unit.h"
diff -u -r --exclude-from exclude fc-adv/po/POTFILES.in
freeciv-mod/po/POTFILES.in
--- fc-adv/po/POTFILES.in Mon Dec 27 22:36:39 1999
+++ freeciv-mod/po/POTFILES.in Wed Dec 29 11:21:34 1999
@@ -5,6 +5,7 @@
common/map.c
common/mem.c
common/shared.c
+common/support.c
common/unit.c
server/cityhand.c
server/citytools.c
diff -u -r --exclude-from exclude fc-adv/server/ruleset.c
freeciv-mod/server/ruleset.c
--- fc-adv/server/ruleset.c Tue Dec 28 23:33:38 1999
+++ freeciv-mod/server/ruleset.c Wed Dec 29 11:27:49 1999
@@ -30,6 +30,7 @@
#include "nation.h"
#include "packets.h"
#include "registry.h"
+#include "support.h"
#include "tech.h"
#include "unit.h"
diff -u -r --exclude-from exclude fc-adv/server/sernet.c
freeciv-mod/server/sernet.c
--- fc-adv/server/sernet.c Sat Sep 18 10:26:33 1999
+++ freeciv-mod/server/sernet.c Wed Dec 29 11:28:13 1999
@@ -60,6 +60,7 @@
#include "log.h"
#include "packets.h"
#include "shared.h"
+#include "support.h" /* mystrerror */
#include "civserver.h"
#include "console.h"
diff -u -r --exclude-from exclude fc-adv/server/stdinhand.c
freeciv-mod/server/stdinhand.c
--- fc-adv/server/stdinhand.c Wed Dec 29 11:14:35 1999
+++ freeciv-mod/server/stdinhand.c Wed Dec 29 11:28:27 1999
@@ -30,6 +30,7 @@
#include "player.h"
#include "registry.h"
#include "shared.h"
+#include "support.h"
#include "civserver.h"
#include "console.h"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] patch: move my* funcs to common/support (PR#214),
David Pfitzner <=
|
|