Author: petdance
Date: Wed Jun 13 12:13:35 2007
New Revision: 18984
Modified:
trunk/config/gen/makefiles/root.in
trunk/src/charset/ascii.c
trunk/src/charset/ascii.h
trunk/src/charset/binary.c
trunk/src/charset/binary.h
trunk/src/charset/iso-8859-1.c
trunk/src/charset/iso-8859-1.h
trunk/src/charset/tables.h
trunk/src/charset/unicode.c
trunk/src/charset/unicode.h
trunk/tools/build/headerize.pl
Log:
headerized all of src/charset/*.*
Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in (original)
+++ trunk/config/gen/makefiles/root.in Wed Jun 13 12:13:35 2007
@@ -1829,6 +1829,7 @@
# Slowing working my way up to having everything headerized in
$(HEADERIZER_O_FILES)
HEADERIZER_O_FILES = \
+ $(CHARSET_O_FILES) \
src/byteorder.o \
src/charset.o \
src/datatypes.o \
@@ -1862,7 +1863,7 @@
src/utils.o \
src/vtables.o \
-headerizer : $(SRC_DIR)/fingerprint.c
+headerizer : $(SRC_DIR)/fingerprint.c
$(PERL) $(BUILD_TOOLS_DIR)/headerize.pl $(HEADERIZER_O_FILES)
###############################################################################
Modified: trunk/src/charset/ascii.c
==============================================================================
--- trunk/src/charset/ascii.c (original)
+++ trunk/src/charset/ascii.c Wed Jun 13 12:13:35 2007
@@ -19,6 +19,8 @@
#include "ascii.h"
#include <assert.h>
+/* HEADER: src/charset/ascii.h */
+
#ifdef EXCEPTION
# undef EXCEPTION
#endif
@@ -32,9 +34,11 @@
#include "tables.h"
+/* XXX Apparently unused, and not part of the API */
INTVAL
-ascii_find_thing(Interp *interp, STRING *string, UINTVAL start,
- PARROT_CCLASS_FLAGS type, const PARROT_CCLASS_FLAGS *table)
+ascii_find_thing(Interp *interp, STRING *string /*NN*/, UINTVAL start,
+ PARROT_CCLASS_FLAGS type, const PARROT_CCLASS_FLAGS *table /*NN*/)
+ /* WARN_UNUSED */
{
for (; start < string->strlen; start++) {
if (table[ENCODING_GET_BYTE(interp, string, start)] & type) {
@@ -45,8 +49,9 @@
}
INTVAL
-ascii_find_not_thing(Interp *interp, STRING *string, UINTVAL start,
- PARROT_CCLASS_FLAGS type, const PARROT_CCLASS_FLAGS *table)
+ascii_find_not_thing(Interp *interp, STRING *string /*NN*/, UINTVAL start,
+ PARROT_CCLASS_FLAGS type, const PARROT_CCLASS_FLAGS *table /*NN*/)
+ /* WARN_UNUSED */
{
for (; start < string->strlen; start++) {
if (!(table[ENCODING_GET_BYTE(interp, string, start)] & type)) {
@@ -59,6 +64,7 @@
STRING *
ascii_get_graphemes(Interp *interp, STRING *source_string,
UINTVAL offset, UINTVAL count)
+ /* WARN_UNUSED */
{
return ENCODING_GET_BYTES(interp, source_string, offset, count);
}
@@ -75,13 +81,15 @@
STRING *
ascii_get_graphemes_inplace(Interp *interp, STRING *source_string,
UINTVAL offset, UINTVAL count, STRING *dest_string)
+ /* WARN_UNUSED */
{
return ENCODING_GET_BYTES_INPLACE(interp, source_string,
offset, count, dest_string);
}
static STRING *
-to_ascii(Interp *interp, STRING *src, STRING *dest)
+to_ascii(Interp *interp, STRING *src /*NN*/, STRING *dest /*NULLOK*/)
+ /* WARN_UNUSED */
{
String_iter iter;
UINTVAL c, len, offs;
@@ -155,7 +163,7 @@
}
static void
-upcase(Interp *interp, STRING *source_string)
+upcase(Interp *interp, STRING *source_string /*NN*/)
{
char *buffer;
UINTVAL offset = 0;
@@ -222,7 +230,7 @@
}
static void
-titlecase_first(Interp *interp, STRING *source_string)
+titlecase_first(Interp *interp, STRING *source_string /*NN*/)
{
char *buffer;
if (!source_string->strlen) {
@@ -234,27 +242,27 @@
}
INTVAL
-ascii_compare(Interp *interp, const STRING *lhs, const STRING *rhs)
+ascii_compare(Interp *interp, const STRING *lhs /*NN*/, const STRING *rhs
/*NN*/)
+ /* WARN_UNUSED */
{
- UINTVAL offs, l_len, r_len, min_len;
String_iter iter;
- l_len = lhs->strlen;
- r_len = rhs->strlen;
- min_len = l_len > r_len ? r_len : l_len;
+ const UINTVAL l_len = lhs->strlen;
+ const UINTVAL r_len = rhs->strlen;
+ const UINTVAL min_len = l_len > r_len ? r_len : l_len;
if (lhs->encoding == Parrot_fixed_8_encoding_ptr &&
rhs->encoding == Parrot_fixed_8_encoding_ptr) {
- int ret_val = memcmp(lhs->strstart, rhs->strstart, min_len);
+ const int ret_val = memcmp(lhs->strstart, rhs->strstart, min_len);
if (ret_val)
return ret_val < 0 ? -1 : 1;
}
else {
- UINTVAL cl, cr;
+ UINTVAL offs;
ENCODING_ITER_INIT(interp, rhs, &iter);
for (offs = 0; offs < min_len; ++offs) {
- cl = ENCODING_GET_BYTE(interp, lhs, offs);
- cr = iter.get_and_advance(interp, &iter);
+ const UINTVAL cl = ENCODING_GET_BYTE(interp, lhs, offs);
+ const UINTVAL cr = iter.get_and_advance(interp, &iter);
if (cl != cr)
return cl < cr ? -1 : 1;
}
@@ -270,6 +278,7 @@
INTVAL
mixed_cs_index(Interp *interp, STRING *src, STRING *search, UINTVAL offs)
+ /* WARN_UNUSED */
{
String_iter src_iter, search_iter;
UINTVAL c1, c2, len;
@@ -303,6 +312,7 @@
INTVAL
ascii_cs_index(Interp *interp, STRING *source_string,
STRING *search_string, UINTVAL offset)
+ /* WARN_UNUSED */
{
INTVAL retval;
if (source_string->charset != search_string->charset) {
@@ -318,7 +328,9 @@
INTVAL
ascii_cs_rindex(Interp *interp, STRING *source_string,
- STRING *search_string, UINTVAL offset) {
+ STRING *search_string, UINTVAL offset)
+ /* WARN_UNUSED */
+{
INTVAL retval;
if (source_string->charset != search_string->charset) {
internal_exception(UNIMPLEMENTED, "Cross-charset index not supported");
@@ -332,6 +344,7 @@
static UINTVAL
validate(Interp *interp, STRING *src)
+ /* WARN_UNUSED */
{
UINTVAL codepoint, offset;
String_iter iter;
@@ -347,15 +360,16 @@
static STRING *
string_from_codepoint(Interp *interp, UINTVAL codepoint)
+ /* WARN_UNUSED */
{
- STRING *return_string = NULL;
char real_codepoint = (char)codepoint;
- return_string = string_make(interp, &real_codepoint, 1, "ascii", 0);
+ STRING * const return_string = string_make(interp, &real_codepoint, 1,
"ascii", 0);
return return_string;
}
static INTVAL
is_cclass(Interp *interp, INTVAL flags, STRING *source_string, UINTVAL offset)
+ /* WARN_UNUSED */
{
UINTVAL codepoint;
@@ -373,6 +387,7 @@
static INTVAL
find_cclass(Interp *interp, INTVAL flags, STRING *source_string,
UINTVAL offset, UINTVAL count)
+ /* WARN_UNUSED */
{
UINTVAL pos = offset;
UINTVAL end = offset + count;
@@ -412,11 +427,12 @@
* TODO pass in the Hash's seed value as initial hashval
*/
size_t
-ascii_compute_hash(Interp *interp, STRING *source_string, size_t seed)
+ascii_compute_hash(Interp *interp, STRING *source_string /*NN*/, size_t seed)
+ /* PURE,WARN_UNUSED */
{
size_t hashval = seed;
- char *buffptr = (char *)source_string->strstart;
+ const char *buffptr = (char *)source_string->strstart;
UINTVAL len = source_string->strlen;
assert(source_string->encoding == Parrot_fixed_8_encoding_ptr);
Modified: trunk/src/charset/ascii.h
==============================================================================
--- trunk/src/charset/ascii.h (original)
+++ trunk/src/charset/ascii.h Wed Jun 13 12:13:35 2007
@@ -17,28 +17,81 @@
* common functions for ascii-ish charsets
*/
-INTVAL
-ascii_find_thing(Interp *interp, STRING *string, UINTVAL start,
- PARROT_CCLASS_FLAGS type, const PARROT_CCLASS_FLAGS *table);
-INTVAL
-ascii_find_not_thing(Interp *interp, STRING *string, UINTVAL start,
- PARROT_CCLASS_FLAGS type, const PARROT_CCLASS_FLAGS *table);
-STRING *ascii_get_graphemes(Interp *, STRING *source_string,
- UINTVAL offset, UINTVAL count);
-STRING *ascii_get_graphemes_inplace(Interp *, STRING *source_string,
- UINTVAL offset, UINTVAL count, STRING *dest_string);
-INTVAL ascii_compare(Interp *, const STRING *lhs, const STRING *rhs);
-INTVAL ascii_cs_index(Interp *, STRING *source_string,
- STRING *search_string, UINTVAL offset);
-INTVAL ascii_cs_rindex(Interp *, STRING *source_string,
- STRING *search_string, UINTVAL offset);
-size_t ascii_compute_hash(Interp *, STRING *source_string, size_t seed);
-INTVAL mixed_cs_index(Interp *, STRING *src, STRING *search, UINTVAL offs);
+/* HEADERIZER BEGIN: src/charset/ascii.c */
-CHARSET *Parrot_charset_ascii_init(Interp *);
+INTVAL ascii_compare( Interp *interp,
+ const STRING *lhs /*NN*/,
+ const STRING *rhs /*NN*/ )
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3)
+ __attribute__warn_unused_result__;
-STRING *charset_cvt_ascii_to_binary(Interp *, STRING *src, STRING *dest);
-STRING *charset_cvt_ascii_to_iso_8859_1(Interp *, STRING *src, STRING *dest);
+size_t ascii_compute_hash( Interp *interp,
+ STRING *source_string /*NN*/,
+ size_t seed )
+ __attribute__nonnull__(2)
+ __attribute__pure__
+ __attribute__warn_unused_result__;
+
+INTVAL ascii_cs_index( Interp *interp,
+ STRING *source_string,
+ STRING *search_string,
+ UINTVAL offset )
+ __attribute__warn_unused_result__;
+
+INTVAL ascii_cs_rindex( Interp *interp,
+ STRING *source_string,
+ STRING *search_string,
+ UINTVAL offset )
+ __attribute__warn_unused_result__;
+
+INTVAL ascii_find_not_thing( Interp *interp,
+ STRING *string /*NN*/,
+ UINTVAL start,
+ PARROT_CCLASS_FLAGS type,
+ const PARROT_CCLASS_FLAGS *table /*NN*/ )
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(5)
+ __attribute__warn_unused_result__;
+
+INTVAL ascii_find_thing( Interp *interp,
+ STRING *string /*NN*/,
+ UINTVAL start,
+ PARROT_CCLASS_FLAGS type,
+ const PARROT_CCLASS_FLAGS *table /*NN*/ )
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(5)
+ __attribute__warn_unused_result__;
+
+STRING * ascii_get_graphemes( Interp *interp,
+ STRING *source_string,
+ UINTVAL offset,
+ UINTVAL count )
+ __attribute__warn_unused_result__;
+
+STRING * ascii_get_graphemes_inplace( Interp *interp,
+ STRING *source_string,
+ UINTVAL offset,
+ UINTVAL count,
+ STRING *dest_string )
+ __attribute__warn_unused_result__;
+
+STRING * charset_cvt_ascii_to_binary( Interp *interp,
+ STRING *src,
+ STRING *dest );
+
+STRING * charset_cvt_ascii_to_iso_8859_1( Interp *interp,
+ STRING *src,
+ STRING *dest );
+
+INTVAL mixed_cs_index( Interp *interp,
+ STRING *src,
+ STRING *search,
+ UINTVAL offs )
+ __attribute__warn_unused_result__;
+
+CHARSET * Parrot_charset_ascii_init( Interp *interp );
+/* HEADERIZER END: src/charset/ascii.c */
#endif /* PARROT_CHARSET_ASCII_H_GUARD */
Modified: trunk/src/charset/binary.c
==============================================================================
--- trunk/src/charset/binary.c (original)
+++ trunk/src/charset/binary.c Wed Jun 13 12:13:35 2007
@@ -15,8 +15,12 @@
*/
#include "parrot/parrot.h"
-#include "binary.h"
+
+/* In local src/charset/ directory */
#include "ascii.h"
+#include "binary.h"
+
+/* HEADER: src/charset/binary.h */
#ifdef EXCEPTION
# undef EXCEPTION
@@ -157,7 +161,7 @@
CHARSET *
Parrot_charset_binary_init(Interp *interp)
{
- CHARSET *return_set = Parrot_new_charset(interp);
+ CHARSET * const return_set = Parrot_new_charset(interp);
static const CHARSET base_set = {
"binary",
ascii_get_graphemes,
Modified: trunk/src/charset/binary.h
==============================================================================
--- trunk/src/charset/binary.h (original)
+++ trunk/src/charset/binary.h Wed Jun 13 12:13:35 2007
@@ -13,7 +13,10 @@
#ifndef PARROT_CHARSET_BINARY_H_GUARD
#define PARROT_CHARSET_BINARY_H_GUARD
-CHARSET *Parrot_charset_binary_init(Interp *);
+/* HEADERIZER BEGIN: src/charset/binary.c */
+
+CHARSET * Parrot_charset_binary_init( Interp *interp );
+/* HEADERIZER END: src/charset/binary.c */
#endif /* PARROT_CHARSET_BINARY_H_GUARD */
Modified: trunk/src/charset/iso-8859-1.c
==============================================================================
--- trunk/src/charset/iso-8859-1.c (original)
+++ trunk/src/charset/iso-8859-1.c Wed Jun 13 12:13:35 2007
@@ -1,5 +1,6 @@
/*
-Copyright (C) 2004, The Perl Foundation.
+ *
+Copyright (C) 2004-2007, The Perl Foundation.
$Id$
=head1 NAME
@@ -10,14 +11,14 @@
This file implements the charset functions for iso-8859-1 data
-=cut
-
*/
#include "parrot/parrot.h"
#include "iso-8859-1.h"
#include "ascii.h"
+/* HEADER: src/charset/iso-8859-1.h */
+
#ifdef EXCEPTION
# undef EXCEPTION
#endif
@@ -328,8 +329,9 @@
CHARSET *
Parrot_charset_iso_8859_1_init(Interp *interp)
+ /* WARN_UNUSED */
{
- CHARSET *return_set = Parrot_new_charset(interp);
+ CHARSET * const return_set = Parrot_new_charset(interp);
static const CHARSET base_set = {
"iso-8859-1",
ascii_get_graphemes,
@@ -363,7 +365,8 @@
}
STRING *
-charset_cvt_iso_8859_1_to_ascii(Interp *interp, STRING *src, STRING *dest)
+charset_cvt_iso_8859_1_to_ascii(Interp *interp, STRING *src /*NN*/, STRING
*dest /*NULLOK*/)
+ /* WARN_UNUSED */
{
UINTVAL offs, c;
if (dest) {
Modified: trunk/src/charset/iso-8859-1.h
==============================================================================
--- trunk/src/charset/iso-8859-1.h (original)
+++ trunk/src/charset/iso-8859-1.h Wed Jun 13 12:13:35 2007
@@ -1,5 +1,5 @@
/* iso_8859_1.h
- * Copyright (C) 2004, The Perl Foundation.
+ * Copyright (C) 2004-2007, The Perl Foundation.
* SVN Info
* $Id$
* Overview:
@@ -13,9 +13,18 @@
#ifndef PARROT_CHARSET_ISO_8859_1_H_GUARD
#define PARROT_CHARSET_ISO_8859_1_H_GUARD
-STRING *charset_cvt_iso_8859_1_to_ascii(Interp *, STRING *src, STRING *dest);
+/* HEADERIZER BEGIN: src/charset/iso-8859-1.c */
-CHARSET *Parrot_charset_iso_8859_1_init(Interp *);
+STRING * charset_cvt_iso_8859_1_to_ascii( Interp *interp,
+ STRING *src /*NN*/,
+ STRING *dest /*NULLOK*/ )
+ __attribute__nonnull__(2)
+ __attribute__warn_unused_result__;
+
+CHARSET * Parrot_charset_iso_8859_1_init( Interp *interp )
+ __attribute__warn_unused_result__;
+
+/* HEADERIZER END: src/charset/iso-8859-1.c */
#endif /* PARROT_CHARSET_ISO_8859_1_H_GUARD */
Modified: trunk/src/charset/tables.h
==============================================================================
--- trunk/src/charset/tables.h (original)
+++ trunk/src/charset/tables.h Wed Jun 13 12:13:35 2007
@@ -1,10 +1,10 @@
/* $id $
- * Copyright (C) 2005, The Perl Foundation.
+ * Copyright (C) 2005-2007, The Perl Foundation.
*
* DO NOT EDIT THIS FILE DIRECTLY!
- * please update the charset/gen_tables.pl script instead.
+ * please update the tools/dev/gen_charset_tables.pl script instead.
*
- * Created by gen_tables.pl jrieks
+ * Created by gen_charset_tables.pl 17580 2007-03-17 22:53:00Z paultcochrane
* Overview:
* This file contains various charset tables.
* Data Structure and Algorithms:
@@ -13,21 +13,23 @@
* References:
*/
+/* HEADER: none */
+
+
#ifndef PARROT_CHARSET_TABLES_H_GUARD
#define PARROT_CHARSET_TABLES_H_GUARD
#include "parrot/cclass.h"
-#include "parrot/parrot.h"
#define WHITESPACE enum_cclass_whitespace
#define WORDCHAR enum_cclass_word
#define PUNCTUATION enum_cclass_punctuation
#define DIGIT enum_cclass_numeric
-extern const INTVAL Parrot_ascii_typetable[256];
-extern const INTVAL Parrot_iso_8859_1_typetable[256];
+extern const PARROT_CCLASS_FLAGS Parrot_iso_8859_1_typetable[256];
+extern const PARROT_CCLASS_FLAGS Parrot_ascii_typetable[256];
#endif /* PARROT_CHARSET_TABLES_H_GUARD */
-
/*
* Local variables:
* c-file-style: "parrot"
* End:
* vim: expandtab shiftwidth=4:
*/
+
Modified: trunk/src/charset/unicode.c
==============================================================================
--- trunk/src/charset/unicode.c (original)
+++ trunk/src/charset/unicode.c Wed Jun 13 12:13:35 2007
@@ -10,8 +10,6 @@
This file implements the charset functions for unicode data
-=cut
-
*/
#include "parrot/parrot.h"
@@ -19,6 +17,8 @@
#include "ascii.h"
#include "tables.h"
+/* HEADER: src/charset/unicode.h */
+
#ifdef EXCEPTION
# undef EXCEPTION
#endif
@@ -531,7 +531,7 @@
CHARSET *
Parrot_charset_unicode_init(Interp *interp)
{
- CHARSET *return_set = Parrot_new_charset(interp);
+ CHARSET * const return_set = Parrot_new_charset(interp);
static const CHARSET base_set = {
"unicode",
get_graphemes,
Modified: trunk/src/charset/unicode.h
==============================================================================
--- trunk/src/charset/unicode.h (original)
+++ trunk/src/charset/unicode.h Wed Jun 13 12:13:35 2007
@@ -1,5 +1,5 @@
/* unicode.h
- * Copyright (C) 2005, The Perl Foundation.
+ * Copyright (C) 2005-2007, The Perl Foundation.
* SVN Info
* $Id$
* Overview:
@@ -17,7 +17,11 @@
* init function
*/
-CHARSET *Parrot_charset_unicode_init(Interp *);
+
+/* HEADERIZER BEGIN: src/charset/unicode.c */
+
+CHARSET * Parrot_charset_unicode_init( Interp *interp );
+/* HEADERIZER END: src/charset/unicode.c */
#endif /* PARROT_CHARSET_UNICODE_H_GUARD */
Modified: trunk/tools/build/headerize.pl
==============================================================================
--- trunk/tools/build/headerize.pl (original)
+++ trunk/tools/build/headerize.pl Wed Jun 13 12:13:35 2007
@@ -287,6 +287,7 @@
die "can't find HEADER directive in '$cfile'"
unless $source =~ m#/\*\s+HEADER:\s+([^*]+?)\s+\*/#s;
my $hfile = $1;
+ next if $hfile eq 'none';
die "'$hfile' not found (referenced from '$cfile')" unless -f $hfile;
my @funcs = extract_functions($source);