Author: sveinung
Date: Tue Sep 15 13:26:01 2015
New Revision: 29893

URL: http://svn.gna.org/viewcvs/freeciv?rev=29893&view=rev
Log:
section files: allow underscore in table names

Store in the table format even if the entity name contains an underscore
character.

This makes ruledit store the obsolete_by field of buildings and the
actor_reqs and target_reqs fields of action enablers in a much more readable
way.

Reported by Marko Lindqvist <cazfi>

See bug #21444

Modified:
    trunk/utility/registry_ini.c

Modified: trunk/utility/registry_ini.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/utility/registry_ini.c?rev=29893&r1=29892&r2=29893&view=diff
==============================================================================
--- trunk/utility/registry_ini.c        (original)
+++ trunk/utility/registry_ini.c        Tue Sep 15 13:26:01 2015
@@ -595,6 +595,14 @@
 }
 
 /**************************************************************************
+  Returns TRUE iff the character is legal in a table entry name.
+**************************************************************************/
+static bool is_legal_table_entry_name(char c, bool num)
+{
+  return (num ? fc_isalnum(c) : fc_isalpha(c)) || c == '_';
+}
+
+/**************************************************************************
   Save the previously filled in section_file to disk.
 
   There is now limited ability to save in the new tabular format
@@ -684,17 +692,17 @@
 
           sz_strlcpy(pentry_name, entry_name(pentry));
           c = first = pentry_name;
-          if (*c == '\0' || !fc_isalpha(*c)) {
+          if (*c == '\0' || !is_legal_table_entry_name(*c, FALSE)) {
             break;
           }
-          for (; *c != '\0' && fc_isalpha(*c); c++) {
+          for (; *c != '\0' && is_legal_table_entry_name(*c, FALSE); c++) {
             /* nothing */
           }
           if (0 != strncmp(c, "0.", 2)) {
             break;
           }
           c += 2;
-          if (*c == '\0' || !fc_isalnum(*c)) {
+          if (*c == '\0' || !is_legal_table_entry_name(*c, TRUE)) {
             break;
           }
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to