]> granicus.if.org Git - postgis/commitdiff
Hopefully fixed bug in int4 and double reader from byte stream (was not
authorSandro Santilli <strk@keybit.net>
Thu, 10 Mar 2005 19:26:19 +0000 (19:26 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 10 Mar 2005 19:26:19 +0000 (19:26 +0000)
working on 64bit machines).

git-svn-id: http://svn.osgeo.org/postgis/trunk@1528 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/lwgparse.c
lwgeom/wktparse.h

index b3985b47227b903d2ceef55675c40e1fb7405298..299a0de1e49ca02ba8e813ba9e995c458359a1dc 100644 (file)
@@ -32,7 +32,7 @@ struct tag_outputstate{
 
 typedef struct tag_outputstate output_state;
 typedef void (*output_func)(tuple* this,output_state* out);
-typedef void (*read_col_func)(const char**f);
+typedef void (*read_col_func)(const uchar**f);
 
 
 
@@ -94,7 +94,7 @@ double *first_point=NULL;
 double *last_point=NULL;
 
 /* External functions */
-extern void init_parser(const char *);
+extern void init_parser(const uchar *);
 
 /* Prototypes */
 tuple* alloc_tuple(output_func of,size_t size);
@@ -131,19 +131,19 @@ void alloc_geomertycollection(void);
 void alloc_counter(void);
 void alloc_empty(void);
 uchar* make_lwgeom(void);
-uchar strhex_readbyte(const char* in);
-uchar read_wkb_byte(const char** in);
-void read_wkb_bytes(const char** in,uchar* out, int cnt);
-int4 read_wkb_int(const char** in);
-double read_wbk_double(const char** in,int convert_from_int);
-void read_wkb_point(const char** b);
-void read_collection(const char** b,read_col_func f);
-void read_collection2(const char** b);
-void parse_wkb(const char** b);
-void alloc_wkb(const char* parser);
-uchar* parse_it(const char* geometry,allocator allocfunc,report_error errfunc);
-uchar* parse_lwg(const char* geometry,allocator allocfunc,report_error errfunc);
-uchar* parse_lwgi(const char* geometry,allocator allocfunc,report_error errfunc);
+uchar strhex_readbyte(const uchar* in);
+uchar read_wkb_byte(const uchar** in);
+void read_wkb_bytes(const uchar** in,uchar* out, int cnt);
+int4 read_wkb_int(const uchar** in);
+double read_wkb_double(const uchar** in,int convert_from_int);
+void read_wkb_point(const uchar** b);
+void read_collection(const uchar** b,read_col_func f);
+void read_collection2(const uchar** b);
+void parse_wkb(const uchar** b);
+void alloc_wkb(const uchar* parser);
+uchar* parse_it(const uchar* geometry,allocator allocfunc,report_error errfunc);
+uchar* parse_lwg(const uchar* geometry,allocator allocfunc,report_error errfunc);
+uchar* parse_lwgi(const uchar* geometry,allocator allocfunc,report_error errfunc);
 
 void
 set_srid(double d_srid)
@@ -654,7 +654,7 @@ static const uchar to_hex[]  = {
        255,255,255,255,255,255,255,255};
 
 uchar
-strhex_readbyte(const char* in)
+strhex_readbyte(const uchar* in)
 {
        if ( *in == 0 ){
                if ( ! ferror_occured){
@@ -666,7 +666,7 @@ strhex_readbyte(const char* in)
 }
 
 uchar
-read_wkb_byte(const char** in)
+read_wkb_byte(const uchar** in)
 {
        uchar ret = strhex_readbyte(*in);
        (*in)+=2;
@@ -676,7 +676,7 @@ read_wkb_byte(const char** in)
 int swap_order;
 
 void
-read_wkb_bytes(const char** in,uchar* out, int cnt)
+read_wkb_bytes(const uchar** in,uchar* out, int cnt)
 {
        if ( ! swap_order ){
                while(cnt--) *out++ = read_wkb_byte(in);
@@ -688,17 +688,17 @@ read_wkb_bytes(const char** in,uchar* out, int cnt)
 }
 
 int4
-read_wkb_int(const char** in)
+read_wkb_int(const uchar** in)
 {
-       int4 ret;
+       int4 ret=0;
        read_wkb_bytes(in,(uchar*)&ret,4);
        return ret;
 }
 
 double
-read_wbk_double(const char** in,int convert_from_int)
+read_wkb_double(const uchar** in,int convert_from_int)
 {
-       double ret;
+       double ret=0;
 
        if ( ! convert_from_int){
                read_wkb_bytes(in,(uchar*)&ret,8);
@@ -711,7 +711,7 @@ read_wbk_double(const char** in,int convert_from_int)
 }
 
 void
-read_wkb_point(const char** b)
+read_wkb_point(const uchar** b)
 {
        int i;
        tuple* p = NULL;
@@ -740,7 +740,7 @@ read_wkb_point(const char** b)
                }
 
                for(i=0;i<the_geom.ndims;i++){
-                       p->uu.points[i]=read_wbk_double(b,the_geom.from_lwgi);
+                       p->uu.points[i]=read_wkb_double(b,the_geom.from_lwgi);
                }
        }
 
@@ -749,7 +749,7 @@ read_wkb_point(const char** b)
 }
 
 void
-read_collection(const char** b,read_col_func f)
+read_collection(const uchar** b,read_col_func f)
 {
        int4 cnt=read_wkb_int(b);
        alloc_counter();
@@ -763,13 +763,13 @@ read_collection(const char** b,read_col_func f)
 }
 
 void
-read_collection2(const char** b)
+read_collection2(const uchar** b)
 {
        return read_collection(b,read_wkb_point);
 }
 
 void
-parse_wkb(const char** b)
+parse_wkb(const uchar** b)
 {
        int4 type;
        uchar xdr = read_wkb_byte(b);
@@ -876,7 +876,7 @@ parse_wkb(const char** b)
 
 
 void
-alloc_wkb(const char* parser)
+alloc_wkb(const uchar* parser)
 {
        parse_wkb(&parser);
 }
@@ -885,7 +885,7 @@ alloc_wkb(const char* parser)
        Parse a string and return a LW_GEOM
 */
 uchar *
-parse_it(const char* geometry,allocator allocfunc,report_error errfunc)
+parse_it(const uchar* geometry,allocator allocfunc,report_error errfunc)
 {
 
        local_malloc = allocfunc;
@@ -904,14 +904,14 @@ parse_it(const char* geometry,allocator allocfunc,report_error errfunc)
 }
 
 uchar *
-parse_lwg(const char* geometry,allocator allocfunc,report_error errfunc)
+parse_lwg(const uchar* geometry,allocator allocfunc,report_error errfunc)
 {
        the_geom.lwgi=0;
        return parse_it(geometry,allocfunc,errfunc);
 }
 
 uchar *
-parse_lwgi(const char* geometry,allocator allocfunc,report_error errfunc)
+parse_lwgi(const uchar* geometry,allocator allocfunc,report_error errfunc)
 {
        the_geom.lwgi=1;
        return parse_it(geometry,allocfunc,errfunc);
index a70555f262f7c73b8168bfbfb94a8bc9c8541890..58381dfef99a55c4573f11f33f51d2d306c4542c 100644 (file)
@@ -60,14 +60,14 @@ void alloc_counter(void);
 void pop(void);
 void popc(void);
 
-void alloc_wkb(const char* parser);
+void alloc_wkb(const uchar* parser);
 /*
        Use these functions to parse and unparse lwgeoms
        You are responsible for freeing the returned memory.
 */
 
-uchar* parse_lwg(const char* wkt,allocator allocfunc,report_error errfunc);
-uchar* parse_lwgi(const char* wkt,allocator allocfunc,report_error errfunc);
+uchar* parse_lwg(const uchar* wkt,allocator allocfunc,report_error errfunc);
+uchar* parse_lwgi(const uchar* wkt,allocator allocfunc,report_error errfunc);
 char* unparse_WKT(uchar* serialized, allocator alloc,freeor free);
 char* unparse_WKB(uchar* serialized, allocator alloc,freeor free, char endian, size_t *outsize, uchar hexform);
 int lwg_parse_yyparse(void);