PERFORCE change 143620 for review

Konrad Jankowski konrad at FreeBSD.org
Tue Jun 17 00:05:06 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=143620

Change 143620 by konrad at vspredator on 2008/06/17 00:04:24

	Some style(9) related cleanup.
	Also, one bug fixed.

Affected files ...

.. //depot/projects/soc2008/konrad_collation/colldef/colldef.c#3 edit

Differences ...

==== //depot/projects/soc2008/konrad_collation/colldef/colldef.c#3 (text+ko) ====

@@ -3,13 +3,6 @@
  *          at Bluemedia Sp. z o. o., Sopot, Poland - www.bluemedia.pl
  *                      All rights reserved.
  *
- * This program is just a demonstration of the first approach to building
- * binary collation table. Parsing is purposefully ugly. Later I will do it
- * in yacc.
- * Now, I don't want to focus on the parsing, but on building the table.
- * This is a much more involved process. I want to experiment to find the
- * best approach.
- *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -46,7 +39,7 @@
 
 #define DEFAULT_IN_FILE		"../colldef_in.src.simple"
 #define DEFAULT_OUT_FILE	"LC_COLLATE"
-#define WEIGHT_TABLE_SIZE	(1<<16)
+#define WEIGHT_TABLE_SIZE	(1 << 16)
 #define NWEIGHTS		4
 
 struct sym_entry {
@@ -58,7 +51,7 @@
 SLIST_HEAD(, sym_entry) head;
 
 /*
- * this will have to be a structure, to at least accomodate symbol chaining
+ * This will have to be a structure, to at least accomodate symbol chaining.
  */
 uint8_t weight_table[WEIGHT_TABLE_SIZE][NWEIGHTS];
 struct weight_uncompressed {
@@ -81,7 +74,8 @@
 	static int counter = 1;
 	struct sym_entry *sym;
 
-	sym = malloc(sizeof(*sym));
+	if ((sym = malloc(sizeof(*sym))) == NULL)
+		err(1, "add_symbol: malloc(%d)", sizeof(*sym));
 	sym->name = strdup(name);
 	sym->val = counter++;
 	SLIST_INSERT_HEAD(&head, sym, sym_next);
@@ -119,7 +113,7 @@
 {
 	int i;
 	struct weight_uncompressed *w = weights_uncompressed;
-	
+
 	for (i = 0; i < WEIGHT_TABLE_SIZE; i++, w++) {
 		if (!w->used)
 			continue;
@@ -161,7 +155,7 @@
 	bzero(weights_uncompressed, sizeof(weights_uncompressed));
 	SLIST_INIT(&head);
 	if (freopen(name, "r", stdin) == NULL)
-		err(1, "freopen: %s", name);	
+		err(1, "freopen: %s", name);
 	while (fgets(buf, sizeof(buf), stdin)) {
 #ifdef DEBUG
 		fputs(buf, stdout);
@@ -175,15 +169,13 @@
 			break;
 		case '\\':
 			codepoint = get_codepoint(buf, &p);
-			/* zamiast strchr uzyc powrotu z get_codepoint */
-			/*assign_weights(codepoint, strchr(buf, ' ') + 1);*/
 			assign_weights(codepoint, p + 1);
 			break;
 
 		}
 	}
 
-	fclose(stdin);	/* no needed - freopen closes */
+	fclose(stdin);	/* not really needed - freopen closes */
 }
 
 int
@@ -210,10 +202,10 @@
 		/* we get literal value, instead of symbol */
 		ret = get_codepoint(p2, &p3);
 		*p = p3 + 1;
-		return ret; 
+		return ret;
 	default:
 		errx(1, "get_weight_val: unrecognized weight symbol: %s\n",
-		    p2);    
+		    p2);
 	}
 }
 
@@ -227,7 +219,6 @@
 	for (i = 0; i < 4; i++) {
 		int val;
 
-		
 		val = get_weight_val(&weights);
 		weights_uncompressed[codepoint].w[i] = val;
 	}


More information about the p4-projects mailing list