Hi, sorry if this is the wrong list, but since I'm not a cp-tools
regular I wanted this to be reviewed.

This adds week-related (first day, minimal number of days in week) to 
the LocaleInformation files. Together with the corresponding changes to
java.util.Calendar and java.util.GregorianCalendar this will eliminate
the need for the gnu.java.locale.Calendar*.java files in Classpath, and
unify our localization.

Obviously this needs to be approved before we can regenerate the locale
files, which needs to be done before we merge in the changes to
Calendar/GregorianCalendar, after which we can delete the
gnu.java.locale.Calendar fiels.

2005-04-06  Sven de Marothy  <[EMAIL PROTECTED]>

        * src/gnu/ldml/Analyzer.java,
        (flattenBranch): Check for null elements.
        * src/gnu/ldml/Parser.java,
        Updated copyright.
        (Parser): Add week-related nodes.
        (SinglyAttributedNode): New parser element.
        * src/gnu/localegen/JavaGenerator.java,
        Updated copyright.
        (computeCalendar): Add support for week-related data.

Index: src/gnu/ldml/Analyzer.java
===================================================================
RCS file: /cvsroot/classpath/cp-tools/src/gnu/ldml/Analyzer.java,v
retrieving revision 1.5
diff -u -r1.5 Analyzer.java
--- src/gnu/ldml/Analyzer.java	30 Jan 2005 02:21:06 -0000	1.5
+++ src/gnu/ldml/Analyzer.java	6 Mar 2005 20:09:09 -0000
@@ -48,11 +48,14 @@
         for (int i = 0; i < stack_sz; i++)
           {
             Element elt = (Element) stack.get(i);
-            if (elt.children.size() != 0)
-              {
-                stack.addAll(elt.children);
-              }
-            table.put(elt.getFullName(), elt);
+	    if(elt != null)
+	      {
+	        if (elt.children.size() != 0)
+                  {
+                    stack.addAll(elt.children);
+                  }
+		table.put(elt.getFullName(), elt);
+	      }
           }
         stack.subList(0, stack_sz).clear();
       }
@@ -298,4 +301,4 @@
         elt = fetchResource(alias);
       }
   }
-}
\ No newline at end of file
+}
Index: src/gnu/ldml/Parser.java
===================================================================
RCS file: /cvsroot/classpath/cp-tools/src/gnu/ldml/Parser.java,v
retrieving revision 1.6
diff -u -r1.6 Parser.java
--- src/gnu/ldml/Parser.java	30 Jan 2005 02:33:09 -0000	1.6
+++ src/gnu/ldml/Parser.java	6 Mar 2005 20:09:10 -0000
@@ -1,6 +1,6 @@
 /*
- * gnu.ldml.Parser Copyright (C) 2004 Free Software Foundation,
- * Inc.
+ * gnu.ldml.Parser Copyright (C) 2005 
+ * Free Software Foundation, Inc.
  *
  * This file is part of GNU Classpath.
  *
@@ -226,6 +226,33 @@
   }
 
   /*
+   * Node with a single attribute.
+   */
+  class SinglyAttributedNode extends EmptyParserElement
+  {
+    Element elt;
+    String attrName;
+
+    public SinglyAttributedNode(String attrName)
+    {
+      this.attrName = attrName;
+    }	
+
+    public void start(String qName, Attributes atts) throws SAXException
+    {
+      super.start(qName, atts);
+      String attr = atts.getValue(attrName);
+      parentElement = elt = new Element(Parser.this, parentElement, qName);
+      elt.defaultType = attr;
+    }
+
+    public void end(String qName)
+    {
+      parentElement = elt.superElement;
+    }
+  }
+
+  /*
    * This is a group which contains a list of element indexed by their type.
    */
   class GroupList extends EmptyParserElement
@@ -550,6 +577,9 @@
     allElements.put("perMille", new Data());
     allElements.put("infinity", new Data());
     allElements.put("nan", new Data());
+    allElements.put("week", new Group());
+    allElements.put("minDays", new SinglyAttributedNode("count"));
+    allElements.put("firstDay", new SinglyAttributedNode("day"));
     allElements.put("am", new Data());
     allElements.put("pm", new Data());
     allElements.put("localizedPatternChars", new Data());
Index: src/gnu/localegen/JavaGenerator.java
===================================================================
RCS file: /cvsroot/classpath/cp-tools/src/gnu/localegen/JavaGenerator.java,v
retrieving revision 1.25
diff -u -r1.25 JavaGenerator.java
--- src/gnu/localegen/JavaGenerator.java	31 Jan 2005 02:35:58 -0000	1.25
+++ src/gnu/localegen/JavaGenerator.java	6 Mar 2005 20:09:10 -0000
@@ -1,6 +1,6 @@
 /*
- * gnu.localegen.JavaGenerator Copyright (C) 2004 Free Software Foundation,
- * Inc.
+ * gnu.localegen.JavaGenerator Copyright (C) 2004, 2005
+ * Free Software Foundation, Inc.
  *
  * This file is part of GNU Classpath.
  *
@@ -550,6 +550,17 @@
         addOrderedListContent(calendarLeaf,
                               "calendar.days.dayContext.dayWidth.wide",
                               "weekdays", gnu.ldml.Constants.daysOrder, 1, 0);
+	/* WEEKS */
+	Element minDays = (Element) calendarLeaf.get("calendar.week.minDays");
+	if(minDays != null)
+          localeContents
+            .add(new StringContent("minNumberOfDaysInFirstWeek", minDays.defaultType));
+
+	Element firstDay = (Element) calendarLeaf.get("calendar.week.firstDay");
+	if(firstDay != null)
+          localeContents
+            .add(new StringContent("firstDayOfWeek", firstDay.defaultType));
+
         /* ERAS */
         ListDataElement eraElement = (ListDataElement) calendarLeaf
           .get("calendar.eras.eraAbbr");
@@ -725,7 +736,7 @@
   {
     String suffix = ("root".equals(locale)) ? "" : "_" + locale;
     o.println("/* LocaleInformation" + suffix + ".java --");
-    o.println("   Copyright (C) 2004  Free Software Foundation, Inc.");
+    o.println("   Copyright (C) 2005  Free Software Foundation, Inc.");
     o.println();
     o.println("This file is part of GNU Classpath.");
     o.println();
_______________________________________________
Cp-tools-discuss mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/cp-tools-discuss

Reply via email to