[Freeciv-Dev] (PR#2317) is_sane_name
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients:; |
Subject: |
[Freeciv-Dev] (PR#2317) is_sane_name |
From: |
"Raimar Falke via RT" <rt@xxxxxxxxxxxxxx> |
Date: |
Tue, 12 Nov 2002 11:17:32 -0800 |
Reply-to: |
rt@xxxxxxxxxxxxxx |
get_sane_name is used as a is_sane_name. Lets rename it.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"I haven't lost my mind - it's backed up on tape somewhere."
Index: client/gui-gtk/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/dialogs.c,v
retrieving revision 1.111
diff -u -r1.111 dialogs.c
--- client/gui-gtk/dialogs.c 2002/11/07 16:04:53 1.111
+++ client/gui-gtk/dialogs.c 2002/11/12 19:13:50
@@ -2308,7 +2308,7 @@
packet.city_style = city_style_idx[selected_style];
sz_strlcpy(packet.name, (char*)s);
- if(!get_sane_name(packet.name)) {
+ if (!is_sane_name(packet.name)) {
append_output_window(_("You must type a legal name."));
return;
}
Index: client/gui-gtk-2.0/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/dialogs.c,v
retrieving revision 1.21
diff -u -r1.21 dialogs.c
--- client/gui-gtk-2.0/dialogs.c 2002/10/27 21:05:16 1.21
+++ client/gui-gtk-2.0/dialogs.c 2002/11/12 19:13:54
@@ -2249,7 +2249,7 @@
packet.city_style = city_style_idx[selected_style];
sz_strlcpy(packet.name, (char*)s);
- if(!get_sane_name(packet.name)) {
+ if (!is_sane_name(packet.name)) {
append_output_window(_("You must type a legal name."));
return;
}
Index: client/gui-mui/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/dialogs.c,v
retrieving revision 1.43
diff -u -r1.43 dialogs.c
--- client/gui-mui/dialogs.c 2002/06/12 07:24:39 1.43
+++ client/gui-mui/dialogs.c 2002/11/12 19:13:58
@@ -1633,7 +1633,7 @@
sz_strlcpy(packet.name, (char*)s);
- if(!get_sane_name(packet.name)) {
+ if (!is_sane_name(packet.name)) {
append_output_window(_("You must type a legal name."));
return;
}
Index: client/gui-win32/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/dialogs.c,v
retrieving revision 1.22
diff -u -r1.22 dialogs.c
--- client/gui-win32/dialogs.c 2002/07/13 13:33:05 1.22
+++ client/gui-win32/dialogs.c 2002/11/12 19:14:02
@@ -320,11 +320,10 @@
ComboBox_GetText(GetDlgItem(hWnd,ID_RACESDLG_LEADER),
packet.name,MAX_LEN_NAME);
- if (!get_sane_name(packet.name))
- {
- append_output_window(_("You must type a legal name."));
- return;
- }
+ if (!is_sane_name(packet.name)) {
+ append_output_window(_("You must type a legal name."));
+ return;
+ }
send_packet_alloc_nation(&aconnection,&packet);
}
Index: client/gui-xaw/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/dialogs.c,v
retrieving revision 1.69
diff -u -r1.69 dialogs.c
--- client/gui-xaw/dialogs.c 2002/08/07 11:21:42 1.69
+++ client/gui-xaw/dialogs.c 2002/11/12 19:14:06
@@ -2364,7 +2364,7 @@
packet.city_style = city_style_idx[selected_style];
sz_strlcpy(packet.name, (char*)dp);
- if(!get_sane_name(packet.name)) {
+ if (!is_sane_name(packet.name)) {
append_output_window(_("You must type a legal name."));
return;
}
Index: common/shared.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/shared.c,v
retrieving revision 1.94
diff -u -r1.94 shared.c
--- common/shared.c 2002/11/07 16:04:54 1.94
+++ common/shared.c 2002/11/12 19:14:09
@@ -370,22 +370,21 @@
/***************************************************************
This is used in sundry places to make sure that names of cities,
players etc. do not contain yucky characters of various sorts.
- Returns the input argument if it points to an acceptable name,
- otherwise returns NULL.
+ Returns TRUE iff the name is acceptable.
FIXME: Not internationalised.
***************************************************************/
-const char *get_sane_name(const char *name)
+bool is_sane_name(const char *name)
{
const char *cp;
/* must not be NULL or empty */
if (!name || *name == '\0') {
- return NULL;
+ return FALSE;
}
/* must begin and end with some non-space character */
if ((*name == ' ') || (*(strchr(name, '\0') - 1) == ' ')) {
- return NULL;
+ return FALSE;
}
/* must be composed entirely of printable ISO 8859-1 characters */
@@ -393,11 +392,11 @@
/* nothing */
}
if (*cp != '\0') {
- return NULL;
+ return FALSE;
}
/* otherwise, it's okay... */
- return name;
+ return TRUE;
}
/***************************************************************
Index: common/shared.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/shared.h,v
retrieving revision 1.104
diff -u -r1.104 shared.h
--- common/shared.h 2002/10/09 20:54:20 1.104
+++ common/shared.h 2002/11/12 19:14:09
@@ -117,7 +117,7 @@
const char *int_to_text(int nr);
const char *population_to_text(int thousand_citizen);
-const char *get_sane_name(const char *name);
+bool is_sane_name(const char *name);
const char *textyear(int year);
int compare_strings(const void *first, const void *second);
int compare_strings_ptrs(const void *first, const void *second);
Index: server/cityhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityhand.c,v
retrieving revision 1.118
diff -u -r1.118 cityhand.c
--- server/cityhand.c 2002/08/14 00:01:57 1.118
+++ server/cityhand.c 2002/11/12 19:14:11
@@ -383,24 +383,22 @@
void handle_city_rename(struct player *pplayer,
struct packet_city_request *preq)
{
- const char *cp;
struct city *pcity = player_find_city_by_id(pplayer, preq->city_id);
if (!pcity) {
return;
}
- cp = get_sane_name(preq->name);
- if (!cp) {
+ if (!is_sane_name(preq->name)) {
notify_player(pplayer, _("Game: %s is not a valid name."), preq->name);
return;
}
- if (!is_allowed_city_name(pplayer, cp, pcity->x, pcity->y, TRUE)) {
+ if (!is_allowed_city_name(pplayer, preq->name, pcity->x, pcity->y, TRUE)) {
return;
}
- sz_strlcpy(pcity->name, cp);
+ sz_strlcpy(pcity->name, preq->name);
city_refresh(pcity);
send_city_info(NULL, pcity);
}
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.262
diff -u -r1.262 stdinhand.c
--- server/stdinhand.c 2002/11/11 10:00:48 1.262
+++ server/stdinhand.c 2002/11/12 19:14:20
@@ -2713,7 +2713,7 @@
return;
}
- if (get_sane_name(arg[1]) == NULL) {
+ if (!is_sane_name(arg[1])) {
cmd_reply(CMD_TEAM, caller, C_SYNTAX, _("Bad team name."));
return;
}
Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.238
diff -u -r1.238 unithand.c
--- server/unithand.c 2002/11/07 15:45:06 1.238
+++ server/unithand.c 2002/11/12 19:14:23
@@ -536,20 +536,18 @@
static void city_build(struct player *pplayer, struct unit *punit,
char *name)
{
- const char *city_name = get_sane_name(name);
-
- if (!city_name) {
+ if (!is_sane_name(name)) {
notify_player_ex(pplayer, punit->x, punit->y, E_NOEVENT,
_("Game: Let's not build a city with "
"such a stupid name."));
return;
}
- if (!is_allowed_city_name(pplayer, city_name, punit->x, punit->y, TRUE)) {
+ if (!is_allowed_city_name(pplayer, name, punit->x, punit->y, TRUE)) {
return;
}
- create_city(pplayer, punit->x, punit->y, city_name);
+ create_city(pplayer, punit->x, punit->y, name);
wipe_unit(punit);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#2317) is_sane_name,
Raimar Falke via RT <=
|
|