From owner-p4-projects@FreeBSD.ORG Tue Jun 17 00:05:06 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id F30C71065670; Tue, 17 Jun 2008 00:05:05 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B572B106566B for ; Tue, 17 Jun 2008 00:05:05 +0000 (UTC) (envelope-from konrad@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id A40FD8FC16 for ; Tue, 17 Jun 2008 00:05:05 +0000 (UTC) (envelope-from konrad@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m5H0550p027605 for ; Tue, 17 Jun 2008 00:05:05 GMT (envelope-from konrad@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m5H055rP027603 for perforce@freebsd.org; Tue, 17 Jun 2008 00:05:05 GMT (envelope-from konrad@FreeBSD.org) Date: Tue, 17 Jun 2008 00:05:05 GMT Message-Id: <200806170005.m5H055rP027603@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to konrad@FreeBSD.org using -f From: Konrad Jankowski To: Perforce Change Reviews Cc: Subject: PERFORCE change 143620 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jun 2008 00:05:06 -0000 http://perforce.freebsd.org/chv.cgi?CH=143620 Change 143620 by konrad@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; }