Commit a1635450 authored by Bruce Momjian's avatar Bruce Momjian

Cleanups needed for indent. Remove };

parent fe97d580
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.23 1997/09/04 13:17:59 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.24 1997/09/05 18:13:45 momjian Exp $
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
* heap_creatr() - Create an uncataloged heap relation * heap_creatr() - Create an uncataloged heap relation
...@@ -262,7 +262,7 @@ heap_creatr(char *name, ...@@ -262,7 +262,7 @@ heap_creatr(char *name,
sprintf(tempname, "temp_%d", relid); sprintf(tempname, "temp_%d", relid);
relname = tempname; relname = tempname;
isTemp = 1; isTemp = 1;
}; }
} }
/* ---------------- /* ----------------
...@@ -1403,7 +1403,7 @@ InitTempRelList(void) ...@@ -1403,7 +1403,7 @@ InitTempRelList(void)
if (tempRels) { if (tempRels) {
free(tempRels->rels); free(tempRels->rels);
free(tempRels); free(tempRels);
}; }
tempRels = (TempRelList*)malloc(sizeof(TempRelList)); tempRels = (TempRelList*)malloc(sizeof(TempRelList));
tempRels->size = TEMP_REL_LIST_SIZE; tempRels->size = TEMP_REL_LIST_SIZE;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.2 1996/10/31 10:59:15 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.3 1997/09/05 18:10:32 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -384,7 +384,6 @@ pg_checkretval(Oid rettype, QueryTreeList *queryTreeList) ...@@ -384,7 +384,6 @@ pg_checkretval(Oid rettype, QueryTreeList *queryTreeList)
tletype = (Oid) ((Param*)thenode)->paramtype; tletype = (Oid) ((Param*)thenode)->paramtype;
else if (IsA(thenode,Expr)) { else if (IsA(thenode,Expr)) {
tletype = Expr tletype = Expr
}
} else if (IsA(thenode,LispList)) { } else if (IsA(thenode,LispList)) {
thenode = lfirst(thenode); thenode = lfirst(thenode);
if (IsA(thenode,Oper)) if (IsA(thenode,Oper))
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.2 1997/03/18 18:40:40 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.3 1997/09/05 18:10:36 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -218,7 +218,7 @@ create_seqscan_path(Rel *rel) ...@@ -218,7 +218,7 @@ create_seqscan_path(Rel *rel)
#if 0 #if 0
if (XfuncMode != XFUNC_OFF) { if (XfuncMode != XFUNC_OFF) {
pathnode->path_cost += pathnode->path_cost +=
xfunc_get_path_cost(pathnode)); xfunc_get_path_cost(pathnode);
} }
#endif #endif
return (pathnode); return (pathnode);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.36 1997/09/01 05:56:34 thomas Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.37 1997/09/05 18:10:42 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1353,7 +1353,7 @@ make_targetlist_expr(ParseState *pstate, ...@@ -1353,7 +1353,7 @@ make_targetlist_expr(ParseState *pstate,
} else } else
if (attrtype != type_id) { if (attrtype != type_id) {
if ((attrtype == INT2OID) && (type_id == INT4OID)) if ((attrtype == INT2OID) && (type_id == INT4OID))
lfirst(expr) = lispInteger (INT2OID); do CASHOID too lfirst(expr) = lispInteger (INT2OID); /* handle CASHOID too*/
else if ((attrtype == FLOAT4OID) && (type_id == FLOAT8OID)) else if ((attrtype == FLOAT4OID) && (type_id == FLOAT8OID))
lfirst(expr) = lispInteger (FLOAT4OID); lfirst(expr) = lispInteger (FLOAT4OID);
else else
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.20 1997/08/24 23:07:28 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.21 1997/09/05 18:10:54 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -481,19 +481,19 @@ S_INIT_LOCK(slock_t *lock) ...@@ -481,19 +481,19 @@ S_INIT_LOCK(slock_t *lock)
static int tas_dummy() static int tas_dummy()
{ {
__asm__(" __asm__(" \n\
tas: /* r3 points to the location of p */ tas: \n\
lwarx 5,0,3 /* r5 = *p */ lwarx 5,0,3 \n\
cmpwi 5,0 /* r5 == 0 ? */ cmpwi 5,0 \n\
bne fail /* if not 0, jump to fail */ bne fail \n\
addi 5,5,1 /* set 1 to r5 */ addi 5,5,1 \n\
stwcx. 5,0,3 /* try update p atomically */ stwcx. 5,0,3 \n\
beq success /* jump if scceed */ beq success \n\
fail: li 3,1 /* set 1 to r3 */ fail: li 3,1 \n\
blr blr \n\
success: success: \n\
li 3,0 /* set 0 to r3 */ li 3,0 \n\
blr blr \n\
"); ");
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.13 1997/08/19 21:34:30 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.14 1997/09/05 18:11:05 momjian Exp $
* *
* NOTES * NOTES
* This code is actually (almost) unused. * This code is actually (almost) unused.
...@@ -144,7 +144,7 @@ printf( "reltimein- %d fields are type %d (DTK_DATE=%d)\n", nf, dtype, DTK_DATE) ...@@ -144,7 +144,7 @@ printf( "reltimein- %d fields are type %d (DTK_DATE=%d)\n", nf, dtype, DTK_DATE)
default: default:
return(INVALID_RELTIME); return(INVALID_RELTIME);
}; }
elog(WARN,"Bad reltime (internal coding error) '%s'",str); elog(WARN,"Bad reltime (internal coding error) '%s'",str);
return(INVALID_RELTIME); return(INVALID_RELTIME);
...@@ -166,7 +166,7 @@ char *reltimeout(int32 time) ...@@ -166,7 +166,7 @@ char *reltimeout(int32 time)
} else { } else {
reltime2tm(time, tm); reltime2tm(time, tm);
EncodeTimeSpan( tm, 0, DateStyle, buf); EncodeTimeSpan( tm, 0, DateStyle, buf);
}; }
result = PALLOC(strlen(buf)+1); result = PALLOC(strlen(buf)+1);
strcpy( result, buf); strcpy( result, buf);
...@@ -305,7 +305,7 @@ timespan_reltime(TimeSpan *timespan) ...@@ -305,7 +305,7 @@ timespan_reltime(TimeSpan *timespan)
} else { } else {
year = 0; year = 0;
month = timespan->month; month = timespan->month;
}; }
span = (((((double) 365*year)+((double) 30*month))*86400) + timespan->time); span = (((((double) 365*year)+((double) 30*month))*86400) + timespan->time);
...@@ -315,7 +315,7 @@ printf( "timespan_reltime- convert m%d s%f to %f [%d %d]\n", ...@@ -315,7 +315,7 @@ printf( "timespan_reltime- convert m%d s%f to %f [%d %d]\n",
#endif #endif
time = (((span > INT_MIN) && (span < INT_MAX))? span: INVALID_RELTIME); time = (((span > INT_MIN) && (span < INT_MAX))? span: INVALID_RELTIME);
}; }
return(time); return(time);
} /* timespan_reltime() */ } /* timespan_reltime() */
...@@ -341,7 +341,7 @@ reltime_timespan(RelativeTime reltime) ...@@ -341,7 +341,7 @@ reltime_timespan(RelativeTime reltime)
result->time = reltime; result->time = reltime;
result->month = ((12*year)+month); result->month = ((12*year)+month);
}; }
return(result); return(result);
} /* reltime_timespan() */ } /* reltime_timespan() */
...@@ -694,7 +694,7 @@ int isreltime(char *str) ...@@ -694,7 +694,7 @@ int isreltime(char *str)
default: default:
return 0; return 0;
break; break;
}; }
return 0; return 0;
} /* isreltime() */ } /* isreltime() */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.12 1997/08/28 05:06:29 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.13 1997/09/05 18:11:10 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -95,7 +95,7 @@ printf( "date_in- input string is %s\n", str); ...@@ -95,7 +95,7 @@ printf( "date_in- input string is %s\n", str);
default: default:
elog(WARN,"Unrecognized date external representation %s",str); elog(WARN,"Unrecognized date external representation %s",str);
}; }
if (tm->tm_year < 0 || tm->tm_year > 32767) if (tm->tm_year < 0 || tm->tm_year > 32767)
elog(WARN, "date_in: year must be limited to values 0 through 32767 in '%s'", str); elog(WARN, "date_in: year must be limited to values 0 through 32767 in '%s'", str);
...@@ -186,7 +186,7 @@ date_cmp(DateADT dateVal1, DateADT dateVal2) ...@@ -186,7 +186,7 @@ date_cmp(DateADT dateVal1, DateADT dateVal2)
return -1; return -1;
} else if (dateVal1 > dateVal2) { } else if (dateVal1 > dateVal2) {
return 1; return 1;
}; }
return 0; return 0;
} /* date_cmp() */ } /* date_cmp() */
...@@ -281,7 +281,7 @@ datetime_date(DateTime *datetime) ...@@ -281,7 +281,7 @@ datetime_date(DateTime *datetime)
} else { } else {
if (datetime2tm( *datetime, &tz, tm, &fsec, &tzn) != 0) if (datetime2tm( *datetime, &tz, tm, &fsec, &tzn) != 0)
elog(WARN,"Unable to convert datetime to date",NULL); elog(WARN,"Unable to convert datetime to date",NULL);
}; }
result = (date2j( tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j( 2000, 1, 1)); result = (date2j( tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j( 2000, 1, 1));
...@@ -319,7 +319,7 @@ abstime_date(AbsoluteTime abstime) ...@@ -319,7 +319,7 @@ abstime_date(AbsoluteTime abstime)
abstime2tm(abstime, &tz, tm, NULL); abstime2tm(abstime, &tz, tm, NULL);
result = date2j(tm->tm_year,tm->tm_mon,tm->tm_mday) - date2j(2000,1,1); result = date2j(tm->tm_year,tm->tm_mon,tm->tm_mday) - date2j(2000,1,1);
break; break;
}; }
return(result); return(result);
} /* abstime_date() */ } /* abstime_date() */
...@@ -404,7 +404,7 @@ printf( "date2tm- convert %d-%d-%d %d:%d%d to datetime\n", ...@@ -404,7 +404,7 @@ printf( "date2tm- convert %d-%d-%d %d:%d%d to datetime\n",
*tzp = 0; *tzp = 0;
tm->tm_isdst = 0; tm->tm_isdst = 0;
if (tzn != NULL) *tzn = NULL; if (tzn != NULL) *tzn = NULL;
}; }
return 0; return 0;
} /* date2tm() */ } /* date2tm() */
...@@ -482,8 +482,8 @@ time_out(TimeADT *time) ...@@ -482,8 +482,8 @@ time_out(TimeADT *time)
sprintf(buf, "%02d:%02d:%02d", hour, min, sec); sprintf(buf, "%02d:%02d:%02d", hour, min, sec);
} else { } else {
sprintf(buf, "%02d:%02d:%05.2f", hour, min, (sec+fsec)); sprintf(buf, "%02d:%02d:%05.2f", hour, min, (sec+fsec));
}; }
}; }
#endif #endif
result = PALLOC(strlen(buf)+1); result = PALLOC(strlen(buf)+1);
...@@ -570,7 +570,7 @@ datetime_datetime(DateADT date, TimeADT *time) ...@@ -570,7 +570,7 @@ datetime_datetime(DateADT date, TimeADT *time)
} else { } else {
result = date_datetime(date); result = date_datetime(date);
*result += *time; *result += *time;
}; }
return(result); return(result);
} /* datetime_datetime() */ } /* datetime_datetime() */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.35 1997/09/04 18:43:21 thomas Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.36 1997/09/05 18:11:12 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -54,13 +54,13 @@ static int tm2timespan(struct tm *tm, double fsec, TimeSpan *span); ...@@ -54,13 +54,13 @@ static int tm2timespan(struct tm *tm, double fsec, TimeSpan *span);
#define isleap(y) (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0))) #define isleap(y) (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0)))
int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}; int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}
char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL}; "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL}
char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday", NULL}; "Thursday", "Friday", "Saturday", NULL}
/* TMODULO() /* TMODULO()
* Macro to replace modf(), which is broken on some platforms. * Macro to replace modf(), which is broken on some platforms.
...@@ -148,7 +148,7 @@ printf( "datetime_in- date is %f\n", *result); ...@@ -148,7 +148,7 @@ printf( "datetime_in- date is %f\n", *result);
default: default:
elog(WARN,"Internal coding error, can't input datetime '%s'",str); elog(WARN,"Internal coding error, can't input datetime '%s'",str);
}; }
return(result); return(result);
} /* datetime_in() */ } /* datetime_in() */
...@@ -177,7 +177,7 @@ datetime_out(DateTime *dt) ...@@ -177,7 +177,7 @@ datetime_out(DateTime *dt)
} else { } else {
EncodeSpecialDateTime(DT_INVALID, buf); EncodeSpecialDateTime(DT_INVALID, buf);
}; }
result = PALLOC(strlen(buf)+1); result = PALLOC(strlen(buf)+1);
...@@ -230,12 +230,12 @@ timespan_in(char *str) ...@@ -230,12 +230,12 @@ timespan_in(char *str)
TIMESPAN_INVALID(span); TIMESPAN_INVALID(span);
#endif #endif
elog(WARN,"Bad timespan external representation %s",str); elog(WARN,"Bad timespan external representation %s",str);
}; }
break; break;
default: default:
elog(WARN,"Internal coding error, can't input timespan '%s'",str); elog(WARN,"Internal coding error, can't input timespan '%s'",str);
}; }
return(span); return(span);
} /* timespan_in() */ } /* timespan_in() */
...@@ -342,7 +342,7 @@ printf( "SetDateTime- current time is %f\n", dt); ...@@ -342,7 +342,7 @@ printf( "SetDateTime- current time is %f\n", dt);
#ifdef DATEDEBUG #ifdef DATEDEBUG
printf( "SetDateTime- epoch time is %f\n", dt); printf( "SetDateTime- epoch time is %f\n", dt);
#endif #endif
}; }
return(dt); return(dt);
} /* SetDateTime() */ } /* SetDateTime() */
...@@ -496,7 +496,7 @@ datetime_cmp(DateTime *datetime1, DateTime *datetime2) ...@@ -496,7 +496,7 @@ datetime_cmp(DateTime *datetime1, DateTime *datetime2)
} else { } else {
if (DATETIME_IS_RELATIVE(dt1)) dt1 = SetDateTime(dt1); if (DATETIME_IS_RELATIVE(dt1)) dt1 = SetDateTime(dt1);
if (DATETIME_IS_RELATIVE(dt2)) dt2 = SetDateTime(dt2); if (DATETIME_IS_RELATIVE(dt2)) dt2 = SetDateTime(dt2);
}; }
return( ((dt1 < dt2)? -1: ((dt1 > dt2)? 1: 0))); return( ((dt1 < dt2)? -1: ((dt1 > dt2)? 1: 0)));
} /* datetime_cmp() */ } /* datetime_cmp() */
...@@ -622,7 +622,7 @@ timespan_cmp(TimeSpan *timespan1, TimeSpan *timespan2) ...@@ -622,7 +622,7 @@ timespan_cmp(TimeSpan *timespan1, TimeSpan *timespan2)
} else if (TIMESPAN_IS_INVALID(*timespan2)) { } else if (TIMESPAN_IS_INVALID(*timespan2)) {
return( -1); return( -1);
}; }
span1 = timespan1->time; span1 = timespan1->time;
if (timespan1->month != 0) span1 += (timespan1->month * (30.0*86400)); if (timespan1->month != 0) span1 += (timespan1->month * (30.0*86400));
...@@ -665,7 +665,7 @@ datetime_smaller(DateTime *datetime1, DateTime *datetime2) ...@@ -665,7 +665,7 @@ datetime_smaller(DateTime *datetime1, DateTime *datetime2)
*result = dt1; *result = dt1;
} else { } else {
*result = ((dt2 < dt1)? dt2: dt1); *result = ((dt2 < dt1)? dt2: dt1);
}; }
return(result); return(result);
} /* datetime_smaller() */ } /* datetime_smaller() */
...@@ -694,7 +694,7 @@ datetime_larger(DateTime *datetime1, DateTime *datetime2) ...@@ -694,7 +694,7 @@ datetime_larger(DateTime *datetime1, DateTime *datetime2)
*result = dt1; *result = dt1;
} else { } else {
*result = ((dt2 > dt1)? dt2: dt1); *result = ((dt2 > dt1)? dt2: dt1);
}; }
return(result); return(result);
} /* datetime_larger() */ } /* datetime_larger() */
...@@ -728,7 +728,7 @@ printf( "datetime_mi- evaluate %f - %f\n", dt1, dt2); ...@@ -728,7 +728,7 @@ printf( "datetime_mi- evaluate %f - %f\n", dt1, dt2);
} else { } else {
result->time = JROUND(dt1 - dt2); result->time = JROUND(dt1 - dt2);
}; }
result->month = 0; result->month = 0;
return(result); return(result);
...@@ -791,7 +791,7 @@ printf( "datetime_pl_span- date was %04d-%02d-%02d %02d:%02d:%02d\n", ...@@ -791,7 +791,7 @@ printf( "datetime_pl_span- date was %04d-%02d-%02d %02d:%02d:%02d\n",
} else if (tm->tm_mon < 1) { } else if (tm->tm_mon < 1) {
tm->tm_year += ((tm->tm_mon / 12) - 1); tm->tm_year += ((tm->tm_mon / 12) - 1);
tm->tm_mon = ((tm->tm_mon % 12) + 12); tm->tm_mon = ((tm->tm_mon % 12) + 12);
}; }
/* adjust for end of month boundary problems... */ /* adjust for end of month boundary problems... */
if (tm->tm_mday > mdays[ tm->tm_mon-1]) { if (tm->tm_mday > mdays[ tm->tm_mon-1]) {
...@@ -799,8 +799,8 @@ printf( "datetime_pl_span- date was %04d-%02d-%02d %02d:%02d:%02d\n", ...@@ -799,8 +799,8 @@ printf( "datetime_pl_span- date was %04d-%02d-%02d %02d:%02d:%02d\n",
tm->tm_mday = (mdays[ tm->tm_mon-1]+1); tm->tm_mday = (mdays[ tm->tm_mon-1]+1);
} else { } else {
tm->tm_mday = mdays[ tm->tm_mon-1]; tm->tm_mday = mdays[ tm->tm_mon-1];
}; }
}; }
#ifdef DATEDEBUG #ifdef DATEDEBUG
printf( "datetime_pl_span- date becomes %04d-%02d-%02d %02d:%02d:%02d\n", printf( "datetime_pl_span- date becomes %04d-%02d-%02d %02d:%02d:%02d\n",
...@@ -811,11 +811,11 @@ printf( "datetime_pl_span- date becomes %04d-%02d-%02d %02d:%02d:%02d\n", ...@@ -811,11 +811,11 @@ printf( "datetime_pl_span- date becomes %04d-%02d-%02d %02d:%02d:%02d\n",
} else { } else {
DATETIME_INVALID(dt); DATETIME_INVALID(dt);
}; }
}; }
*result = dt; *result = dt;
}; }
return(result); return(result);
} /* datetime_pl_span() */ } /* datetime_pl_span() */
...@@ -893,8 +893,8 @@ printf( "timespan_smaller- months %d %d times %f %f spans %f %f\n", ...@@ -893,8 +893,8 @@ printf( "timespan_smaller- months %d %d times %f %f spans %f %f\n",
} else { } else {
result->time = timespan1->time; result->time = timespan1->time;
result->month = timespan1->month; result->month = timespan1->month;
}; }
}; }
return(result); return(result);
} /* timespan_smaller() */ } /* timespan_smaller() */
...@@ -937,8 +937,8 @@ printf( "timespan_larger- months %d %d times %f %f spans %f %f\n", ...@@ -937,8 +937,8 @@ printf( "timespan_larger- months %d %d times %f %f spans %f %f\n",
} else { } else {
result->time = timespan1->time; result->time = timespan1->time;
result->month = timespan1->month; result->month = timespan1->month;
}; }
}; }
return(result); return(result);
} /* timespan_larger() */ } /* timespan_larger() */
...@@ -1047,22 +1047,22 @@ datetime_age(DateTime *datetime1, DateTime *datetime2) ...@@ -1047,22 +1047,22 @@ datetime_age(DateTime *datetime1, DateTime *datetime2)
tm->tm_mday = -tm->tm_mday; tm->tm_mday = -tm->tm_mday;
tm->tm_mon = -tm->tm_mon; tm->tm_mon = -tm->tm_mon;
tm->tm_year = -tm->tm_year; tm->tm_year = -tm->tm_year;
}; }
if (tm->tm_sec < 0) { if (tm->tm_sec < 0) {
tm->tm_sec += 60; tm->tm_sec += 60;
tm->tm_min--; tm->tm_min--;
}; }
if (tm->tm_min < 0) { if (tm->tm_min < 0) {
tm->tm_min += 60; tm->tm_min += 60;
tm->tm_hour--; tm->tm_hour--;
}; }
if (tm->tm_hour < 0) { if (tm->tm_hour < 0) {
tm->tm_hour += 24; tm->tm_hour += 24;
tm->tm_mday--; tm->tm_mday--;
}; }
if (tm->tm_mday < 0) { if (tm->tm_mday < 0) {
if (dt1 < dt2) { if (dt1 < dt2) {
...@@ -1073,13 +1073,13 @@ datetime_age(DateTime *datetime1, DateTime *datetime2) ...@@ -1073,13 +1073,13 @@ datetime_age(DateTime *datetime1, DateTime *datetime2)
tm->tm_mday += mdays[tm2->tm_mon-1]; tm->tm_mday += mdays[tm2->tm_mon-1];
if (isleap(tm2->tm_year) && (tm2->tm_mon == 2)) tm->tm_mday++; if (isleap(tm2->tm_year) && (tm2->tm_mon == 2)) tm->tm_mday++;
tm->tm_mon--; tm->tm_mon--;
}; }
}; }
if (tm->tm_mon < 0) { if (tm->tm_mon < 0) {
tm->tm_mon += 12; tm->tm_mon += 12;
tm->tm_year--; tm->tm_year--;
}; }
/* recover sign if necessary... */ /* recover sign if necessary... */
if (dt1 < dt2) { if (dt1 < dt2) {
...@@ -1090,11 +1090,11 @@ datetime_age(DateTime *datetime1, DateTime *datetime2) ...@@ -1090,11 +1090,11 @@ datetime_age(DateTime *datetime1, DateTime *datetime2)
tm->tm_mday = -tm->tm_mday; tm->tm_mday = -tm->tm_mday;
tm->tm_mon = -tm->tm_mon; tm->tm_mon = -tm->tm_mon;
tm->tm_year = -tm->tm_year; tm->tm_year = -tm->tm_year;
}; }
if (tm2timespan(tm, fsec, result) != 0) { if (tm2timespan(tm, fsec, result) != 0) {
elog(WARN,"Unable to decode datetime",NULL); elog(WARN,"Unable to decode datetime",NULL);
}; }
#if FALSE #if FALSE
result->time = (fsec2 - fsec1); result->time = (fsec2 - fsec1);
...@@ -1109,7 +1109,7 @@ datetime_age(DateTime *datetime1, DateTime *datetime2) ...@@ -1109,7 +1109,7 @@ datetime_age(DateTime *datetime1, DateTime *datetime2)
} else { } else {
elog(WARN,"Unable to decode datetime",NULL); elog(WARN,"Unable to decode datetime",NULL);
}; }
return(result); return(result);
} /* datetime_age() */ } /* datetime_age() */
...@@ -1266,7 +1266,7 @@ datetime_trunc(text *units, DateTime *datetime) ...@@ -1266,7 +1266,7 @@ datetime_trunc(text *units, DateTime *datetime)
#if FALSE #if FALSE
if (type == IGNORE) { if (type == IGNORE) {
type = DecodeSpecial( 0, lowunits, &val); type = DecodeSpecial( 0, lowunits, &val);
}; }
#endif #endif
#ifdef DATEDEBUG #ifdef DATEDEBUG
...@@ -1319,7 +1319,7 @@ printf( "datetime_trunc- units %s type=%d value=%d\n", lowunits, type, val); ...@@ -1319,7 +1319,7 @@ printf( "datetime_trunc- units %s type=%d value=%d\n", lowunits, type, val);
default: default:
elog(WARN,"Datetime units %s not supported",lowunits); elog(WARN,"Datetime units %s not supported",lowunits);
result = NULL; result = NULL;
}; }
if (IS_VALID_UTIME( tm->tm_year, tm->tm_mon, tm->tm_mday)) { if (IS_VALID_UTIME( tm->tm_year, tm->tm_mon, tm->tm_mday)) {
#ifdef USE_POSIX_TIME #ifdef USE_POSIX_TIME
...@@ -1344,7 +1344,7 @@ printf( "datetime_trunc- units %s type=%d value=%d\n", lowunits, type, val); ...@@ -1344,7 +1344,7 @@ printf( "datetime_trunc- units %s type=%d value=%d\n", lowunits, type, val);
} else { } else {
tm->tm_isdst = 0; tm->tm_isdst = 0;
tz = 0; tz = 0;
}; }
if (tm2datetime( tm, fsec, &tz, result) != 0) if (tm2datetime( tm, fsec, &tz, result) != 0)
elog(WARN,"Unable to truncate datetime to %s",lowunits); elog(WARN,"Unable to truncate datetime to %s",lowunits);
...@@ -1358,8 +1358,8 @@ printf( "datetime_trunc- units %s type=%d value=%d\n", lowunits, type, val); ...@@ -1358,8 +1358,8 @@ printf( "datetime_trunc- units %s type=%d value=%d\n", lowunits, type, val);
} else { } else {
elog(WARN,"Datetime units %s not recognized",lowunits); elog(WARN,"Datetime units %s not recognized",lowunits);
result = NULL; result = NULL;
}; }
}; }
return(result); return(result);
} /* datetime_trunc() */ } /* datetime_trunc() */
...@@ -1392,7 +1392,7 @@ timespan_trunc(text *units, TimeSpan *timespan) ...@@ -1392,7 +1392,7 @@ timespan_trunc(text *units, TimeSpan *timespan)
#if FALSE #if FALSE
if (type == IGNORE) { if (type == IGNORE) {
type = DecodeSpecial( 0, lowunits, &val); type = DecodeSpecial( 0, lowunits, &val);
}; }
#endif #endif
#ifdef DATEDEBUG #ifdef DATEDEBUG
...@@ -1443,7 +1443,7 @@ printf( "timespan_trunc- units %s type=%d value=%d\n", lowunits, type, val); ...@@ -1443,7 +1443,7 @@ printf( "timespan_trunc- units %s type=%d value=%d\n", lowunits, type, val);
default: default:
elog(WARN,"Timespan units %s not supported",lowunits); elog(WARN,"Timespan units %s not supported",lowunits);
result = NULL; result = NULL;
}; }
if (tm2timespan(tm, fsec, result) != 0) if (tm2timespan(tm, fsec, result) != 0)
elog(WARN,"Unable to truncate timespan to %s",lowunits); elog(WARN,"Unable to truncate timespan to %s",lowunits);
...@@ -1451,7 +1451,7 @@ printf( "timespan_trunc- units %s type=%d value=%d\n", lowunits, type, val); ...@@ -1451,7 +1451,7 @@ printf( "timespan_trunc- units %s type=%d value=%d\n", lowunits, type, val);
} else { } else {
elog(NOTICE,"Timespan out of range",NULL); elog(NOTICE,"Timespan out of range",NULL);
result = NULL; result = NULL;
}; }
#if FALSE #if FALSE
} else if ((type == RESERV) && (val == DTK_EPOCH)) { } else if ((type == RESERV) && (val == DTK_EPOCH)) {
...@@ -1459,13 +1459,13 @@ printf( "timespan_trunc- units %s type=%d value=%d\n", lowunits, type, val); ...@@ -1459,13 +1459,13 @@ printf( "timespan_trunc- units %s type=%d value=%d\n", lowunits, type, val);
if (timespan->month != 0) { if (timespan->month != 0) {
*result += ((365.25*86400)*(timespan->month / 12)); *result += ((365.25*86400)*(timespan->month / 12));
*result += ((30*86400)*(timespan->month % 12)); *result += ((30*86400)*(timespan->month % 12));
}; }
#endif #endif
} else { } else {
elog(WARN,"Timespan units %s not recognized",units); elog(WARN,"Timespan units %s not recognized",units);
result = NULL; result = NULL;
}; }
return(result); return(result);
} /* timespan_trunc() */ } /* timespan_trunc() */
...@@ -1501,7 +1501,7 @@ datetime_part(text *units, DateTime *datetime) ...@@ -1501,7 +1501,7 @@ datetime_part(text *units, DateTime *datetime)
type = DecodeUnits( 0, lowunits, &val); type = DecodeUnits( 0, lowunits, &val);
if (type == IGNORE) { if (type == IGNORE) {
type = DecodeSpecial( 0, lowunits, &val); type = DecodeSpecial( 0, lowunits, &val);
}; }
#ifdef DATEDEBUG #ifdef DATEDEBUG
if (type == IGNORE) strcpy(lowunits, "(unknown)"); if (type == IGNORE) strcpy(lowunits, "(unknown)");
...@@ -1575,7 +1575,7 @@ printf( "datetime_part- units %s type=%d value=%d\n", lowunits, type, val); ...@@ -1575,7 +1575,7 @@ printf( "datetime_part- units %s type=%d value=%d\n", lowunits, type, val);
default: default:
elog(WARN,"Datetime units %s not supported",lowunits); elog(WARN,"Datetime units %s not supported",lowunits);
*result = 0; *result = 0;
}; }
} else if (type == RESERV) { } else if (type == RESERV) {
switch (val) { switch (val) {
...@@ -1594,13 +1594,13 @@ printf( "datetime_part- units %s type=%d value=%d\n", lowunits, type, val); ...@@ -1594,13 +1594,13 @@ printf( "datetime_part- units %s type=%d value=%d\n", lowunits, type, val);
default: default:
elog(WARN,"Datetime units %s not supported",lowunits); elog(WARN,"Datetime units %s not supported",lowunits);
*result = 0; *result = 0;
}; }
} else { } else {
elog(WARN,"Datetime units %s not recognized",lowunits); elog(WARN,"Datetime units %s not recognized",lowunits);
*result = 0; *result = 0;
}; }
}; }
return(result); return(result);
} /* datetime_part() */ } /* datetime_part() */
...@@ -1633,7 +1633,7 @@ timespan_part(text *units, TimeSpan *timespan) ...@@ -1633,7 +1633,7 @@ timespan_part(text *units, TimeSpan *timespan)
type = DecodeUnits( 0, lowunits, &val); type = DecodeUnits( 0, lowunits, &val);
if (type == IGNORE) { if (type == IGNORE) {
type = DecodeSpecial( 0, lowunits, &val); type = DecodeSpecial( 0, lowunits, &val);
}; }
#ifdef DATEDEBUG #ifdef DATEDEBUG
if (type == IGNORE) strcpy(lowunits, "(unknown)"); if (type == IGNORE) strcpy(lowunits, "(unknown)");
...@@ -1701,24 +1701,24 @@ printf( "timespan_part- units %s type=%d value=%d\n", lowunits, type, val); ...@@ -1701,24 +1701,24 @@ printf( "timespan_part- units %s type=%d value=%d\n", lowunits, type, val);
default: default:
elog(WARN,"Timespan units %s not yet supported",units); elog(WARN,"Timespan units %s not yet supported",units);
result = NULL; result = NULL;
}; }
} else { } else {
elog(NOTICE,"Timespan out of range",NULL); elog(NOTICE,"Timespan out of range",NULL);
*result = 0; *result = 0;
}; }
} else if ((type == RESERV) && (val == DTK_EPOCH)) { } else if ((type == RESERV) && (val == DTK_EPOCH)) {
*result = timespan->time; *result = timespan->time;
if (timespan->month != 0) { if (timespan->month != 0) {
*result += ((365.25*86400)*(timespan->month / 12)); *result += ((365.25*86400)*(timespan->month / 12));
*result += ((30*86400)*(timespan->month % 12)); *result += ((30*86400)*(timespan->month % 12));
}; }
} else { } else {
elog(WARN,"Timespan units %s not recognized",units); elog(WARN,"Timespan units %s not recognized",units);
*result = 0; *result = 0;
}; }
return(result); return(result);
} /* timespan_part() */ } /* timespan_part() */
...@@ -1791,7 +1791,7 @@ printf( "datetime_zone- zone %s type=%d value=%d\n", lowzone, type, val); ...@@ -1791,7 +1791,7 @@ printf( "datetime_zone- zone %s type=%d value=%d\n", lowzone, type, val);
} else { } else {
elog(WARN,"Time zone %s not recognized",lowzone); elog(WARN,"Time zone %s not recognized",lowzone);
result = NULL; result = NULL;
}; }
return(result); return(result);
} /* datetime_zone() */ } /* datetime_zone() */
...@@ -1961,7 +1961,7 @@ static datetkn datetktbl[] = { ...@@ -1961,7 +1961,7 @@ static datetkn datetktbl[] = {
{ "zp6", TZ, NEG(36)}, /* GMT +6 hours. */ { "zp6", TZ, NEG(36)}, /* GMT +6 hours. */
{ "z", RESERV, DTK_ZULU}, /* 00:00:00 */ { "z", RESERV, DTK_ZULU}, /* 00:00:00 */
{ ZULU, RESERV, DTK_ZULU}, /* 00:00:00 */ { ZULU, RESERV, DTK_ZULU}, /* 00:00:00 */
}; }
static unsigned int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0]; static unsigned int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0];
...@@ -2031,14 +2031,14 @@ static datetkn deltatktbl[] = { ...@@ -2031,14 +2031,14 @@ static datetkn deltatktbl[] = {
{ "years", UNITS, DTK_YEAR}, /* "years" relative time units */ { "years", UNITS, DTK_YEAR}, /* "years" relative time units */
{ "yr", UNITS, DTK_YEAR}, /* "year" relative time units */ { "yr", UNITS, DTK_YEAR}, /* "year" relative time units */
{ "yrs", UNITS, DTK_YEAR}, /* "years" relative time units */ { "yrs", UNITS, DTK_YEAR}, /* "years" relative time units */
}; }
static unsigned int szdeltatktbl = sizeof deltatktbl / sizeof deltatktbl[0]; static unsigned int szdeltatktbl = sizeof deltatktbl / sizeof deltatktbl[0];
#if USE_DATE_CACHE #if USE_DATE_CACHE
datetkn *datecache[MAXDATEFIELDS] = {NULL}; datetkn *datecache[MAXDATEFIELDS] = {NULL}
datetkn *deltacache[MAXDATEFIELDS] = {NULL}; datetkn *deltacache[MAXDATEFIELDS] = {NULL}
#endif #endif
...@@ -2143,7 +2143,7 @@ datetime2tm( DateTime dt, int *tzp, struct tm *tm, double *fsec, char **tzn) ...@@ -2143,7 +2143,7 @@ datetime2tm( DateTime dt, int *tzp, struct tm *tm, double *fsec, char **tzn)
if (time < 0) { if (time < 0) {
time += 86400; time += 86400;
date -= 1; date -= 1;
}; }
/* Julian day routine does not work for negative Julian days */ /* Julian day routine does not work for negative Julian days */
if (date < -date0) if (date < -date0)
...@@ -2230,14 +2230,14 @@ printf( "datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s dst=%d\n", ...@@ -2230,14 +2230,14 @@ printf( "datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s dst=%d\n",
*tzp = 0; *tzp = 0;
tm->tm_isdst = 0; tm->tm_isdst = 0;
if (tzn != NULL) *tzn = NULL; if (tzn != NULL) *tzn = NULL;
}; }
dt = dt2local( dt, *tzp); dt = dt2local( dt, *tzp);
} else { } else {
tm->tm_isdst = 0; tm->tm_isdst = 0;
if (tzn != NULL) *tzn = NULL; if (tzn != NULL) *tzn = NULL;
}; }
#ifdef DATEDEBUG #ifdef DATEDEBUG
printf( "datetime2tm- date is %d.%02d.%02d\n", tm->tm_year, tm->tm_mon, tm->tm_mday); printf( "datetime2tm- date is %d.%02d.%02d\n", tm->tm_year, tm->tm_mon, tm->tm_mday);
...@@ -2299,7 +2299,7 @@ timespan2tm(TimeSpan span, struct tm *tm, float8 *fsec) ...@@ -2299,7 +2299,7 @@ timespan2tm(TimeSpan span, struct tm *tm, float8 *fsec)
} else { } else {
tm->tm_year = 0; tm->tm_year = 0;
tm->tm_mon = 0; tm->tm_mon = 0;
}; }
#ifdef ROUND_ALL #ifdef ROUND_ALL
time = JROUND(span.time); time = JROUND(span.time);
...@@ -2411,7 +2411,7 @@ printf( "ParseDateTime- input string is %s\n", timestr); ...@@ -2411,7 +2411,7 @@ printf( "ParseDateTime- input string is %s\n", timestr);
/* otherwise, number only and will determine year, month, or day later */ /* otherwise, number only and will determine year, month, or day later */
} else { } else {
ftype[nf] = DTK_NUMBER; ftype[nf] = DTK_NUMBER;
}; }
/* text? then date string, month, day of week, special, or timezone */ /* text? then date string, month, day of week, special, or timezone */
} else if (isalpha(*cp)) { } else if (isalpha(*cp)) {
...@@ -2424,7 +2424,7 @@ printf( "ParseDateTime- input string is %s\n", timestr); ...@@ -2424,7 +2424,7 @@ printf( "ParseDateTime- input string is %s\n", timestr);
ftype[nf] = DTK_DATE; ftype[nf] = DTK_DATE;
while (isdigit(*cp) || (*cp == '-') || (*cp == '/') || (*cp == '.')) while (isdigit(*cp) || (*cp == '-') || (*cp == '/') || (*cp == '.'))
*lp++ = tolower(*cp++); *lp++ = tolower(*cp++);
}; }
/* skip leading spaces */ /* skip leading spaces */
} else if (isspace(*cp)) { } else if (isspace(*cp)) {
...@@ -2451,7 +2451,7 @@ printf( "ParseDateTime- input string is %s\n", timestr); ...@@ -2451,7 +2451,7 @@ printf( "ParseDateTime- input string is %s\n", timestr);
/* otherwise something wrong... */ /* otherwise something wrong... */
} else { } else {
return -1; return -1;
}; }
/* ignore punctuation but use as delimiter */ /* ignore punctuation but use as delimiter */
} else if (ispunct(*cp)) { } else if (ispunct(*cp)) {
...@@ -2460,18 +2460,18 @@ printf( "ParseDateTime- input string is %s\n", timestr); ...@@ -2460,18 +2460,18 @@ printf( "ParseDateTime- input string is %s\n", timestr);
} else { } else {
return -1; return -1;
}; }
/* force in a delimiter */ /* force in a delimiter */
*lp++ = '\0'; *lp++ = '\0';
nf++; nf++;
if (nf > MAXDATEFIELDS) { if (nf > MAXDATEFIELDS) {
return -1; return -1;
}; }
#ifdef DATEDEBUG #ifdef DATEDEBUG
printf( "ParseDateTime- set field[%d] to %s type %d\n", (nf-1), field[nf-1], ftype[nf-1]); printf( "ParseDateTime- set field[%d] to %s type %d\n", (nf-1), field[nf-1], ftype[nf-1]);
#endif #endif
}; }
*numfields = nf; *numfields = nf;
...@@ -2547,7 +2547,7 @@ printf( "DecodeDateTime- field[%d] is %s (type %d)\n", i, field[i], ftype[i]); ...@@ -2547,7 +2547,7 @@ printf( "DecodeDateTime- field[%d] is %s (type %d)\n", i, field[i], ftype[i]);
} else { } else {
if (DecodeNumber( flen, field[i], fmask, &tmask, tm, fsec) != 0) if (DecodeNumber( flen, field[i], fmask, &tmask, tm, fsec) != 0)
return -1; return -1;
}; }
break; break;
case DTK_STRING: case DTK_STRING:
...@@ -2614,7 +2614,7 @@ printf( "DecodeDateTime- RESERV field %s value is %d\n", field[i], val); ...@@ -2614,7 +2614,7 @@ printf( "DecodeDateTime- RESERV field %s value is %d\n", field[i], val);
default: default:
*dtype = val; *dtype = val;
}; }
break; break;
...@@ -2664,12 +2664,12 @@ printf( "DecodeDateTime- month field %s value is %d\n", field[i], val); ...@@ -2664,12 +2664,12 @@ printf( "DecodeDateTime- month field %s value is %d\n", field[i], val);
default: default:
return -1; return -1;
}; }
break; break;
default: default:
return -1; return -1;
}; }
#ifdef DATEDEBUG #ifdef DATEDEBUG
printf( "DecodeDateTime- field[%d] %s (%08x/%08x) value is %d\n", printf( "DecodeDateTime- field[%d] %s (%08x/%08x) value is %d\n",
...@@ -2678,7 +2678,7 @@ printf( "DecodeDateTime- field[%d] %s (%08x/%08x) value is %d\n", ...@@ -2678,7 +2678,7 @@ printf( "DecodeDateTime- field[%d] %s (%08x/%08x) value is %d\n",
if (tmask & fmask) return -1; if (tmask & fmask) return -1;
fmask |= tmask; fmask |= tmask;
}; }
/* there is no year zero in AD/BC notation; i.e. "1 BC" == year 0 */ /* there is no year zero in AD/BC notation; i.e. "1 BC" == year 0 */
if (bc) tm->tm_year = -(tm->tm_year-1); if (bc) tm->tm_year = -(tm->tm_year-1);
...@@ -2725,8 +2725,8 @@ printf( " %02d:%02d:%02d\n", tm->tm_hour, tm->tm_min, tm->tm_sec); ...@@ -2725,8 +2725,8 @@ printf( " %02d:%02d:%02d\n", tm->tm_hour, tm->tm_min, tm->tm_sec);
} else { } else {
tm->tm_isdst = 0; tm->tm_isdst = 0;
*tzp = 0; *tzp = 0;
}; }
}; }
return 0; return 0;
} /* DecodeDateTime() */ } /* DecodeDateTime() */
...@@ -2799,7 +2799,7 @@ printf( "DecodeTimeOnly- RESERV field %s value is %d\n", field[i], val); ...@@ -2799,7 +2799,7 @@ printf( "DecodeTimeOnly- RESERV field %s value is %d\n", field[i], val);
default: default:
return -1; return -1;
}; }
break; break;
...@@ -2812,12 +2812,12 @@ printf( "DecodeTimeOnly- RESERV field %s value is %d\n", field[i], val); ...@@ -2812,12 +2812,12 @@ printf( "DecodeTimeOnly- RESERV field %s value is %d\n", field[i], val);
default: default:
return -1; return -1;
}; }
break; break;
default: default:
return -1; return -1;
}; }
if (tmask & fmask) return -1; if (tmask & fmask) return -1;
fmask |= tmask; fmask |= tmask;
...@@ -2825,7 +2825,7 @@ printf( "DecodeTimeOnly- RESERV field %s value is %d\n", field[i], val); ...@@ -2825,7 +2825,7 @@ printf( "DecodeTimeOnly- RESERV field %s value is %d\n", field[i], val);
#ifdef DATEDEBUG #ifdef DATEDEBUG
printf( "DecodeTimeOnly- field[%d] %s value is %d\n", i, field[i], val); printf( "DecodeTimeOnly- field[%d] %s value is %d\n", i, field[i], val);
#endif #endif
}; }
#ifdef DATEDEBUG #ifdef DATEDEBUG
printf( "DecodeTimeOnly- mask %08x (%08x)", fmask, DTK_TIME_M); printf( "DecodeTimeOnly- mask %08x (%08x)", fmask, DTK_TIME_M);
...@@ -2867,11 +2867,11 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm *tm) ...@@ -2867,11 +2867,11 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm *tm)
while (isdigit(*str)) str++; while (isdigit(*str)) str++;
} else if (isalpha(*str)) { } else if (isalpha(*str)) {
while (isalpha(*str)) str++; while (isalpha(*str)) str++;
}; }
if (*str != '\0') *str++ = '\0'; if (*str != '\0') *str++ = '\0';
nf++; nf++;
}; }
/* don't allow too many fields */ /* don't allow too many fields */
if (nf > 3) return -1; if (nf > 3) return -1;
...@@ -2898,7 +2898,7 @@ printf( "DecodeDate- month field %s value is %d\n", field[i], val); ...@@ -2898,7 +2898,7 @@ printf( "DecodeDate- month field %s value is %d\n", field[i], val);
printf( "DecodeDate- illegal field %s value is %d\n", field[i], val); printf( "DecodeDate- illegal field %s value is %d\n", field[i], val);
#endif #endif
return -1; return -1;
}; }
if (fmask & dmask) return -1; if (fmask & dmask) return -1;
fmask |= dmask; fmask |= dmask;
...@@ -2906,8 +2906,8 @@ printf( "DecodeDate- illegal field %s value is %d\n", field[i], val); ...@@ -2906,8 +2906,8 @@ printf( "DecodeDate- illegal field %s value is %d\n", field[i], val);
/* mark this field as being completed */ /* mark this field as being completed */
field[i] = NULL; field[i] = NULL;
}; }
}; }
/* now pick up remaining numeric fields */ /* now pick up remaining numeric fields */
for (i = 0; i < nf; i++) { for (i = 0; i < nf; i++) {
...@@ -2923,7 +2923,7 @@ printf( "DecodeDate- illegal field %s value is %d\n", field[i], val); ...@@ -2923,7 +2923,7 @@ printf( "DecodeDate- illegal field %s value is %d\n", field[i], val);
fmask |= dmask; fmask |= dmask;
*tmask |= dmask; *tmask |= dmask;
}; }
return 0; return 0;
} /* DecodeDate() */ } /* DecodeDate() */
...@@ -2963,8 +2963,8 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm *tm, double *fsec) ...@@ -2963,8 +2963,8 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm *tm, double *fsec)
if (cp == str) return -1; if (cp == str) return -1;
} else { } else {
return -1; return -1;
}; }
}; }
/* do a sanity check */ /* do a sanity check */
if ((tm->tm_hour < 0) if ((tm->tm_hour < 0)
...@@ -2991,7 +2991,7 @@ DecodeNumber( int flen, char *str, int fmask, int *tmask, struct tm *tm, double ...@@ -2991,7 +2991,7 @@ DecodeNumber( int flen, char *str, int fmask, int *tmask, struct tm *tm, double
if (*cp == '.') { if (*cp == '.') {
*fsec = strtod( cp, &cp); *fsec = strtod( cp, &cp);
if (*cp != '\0') return -1; if (*cp != '\0') return -1;
}; }
#ifdef DATEDEBUG #ifdef DATEDEBUG
printf( "DecodeNumber- %s is %d fmask=%08x tmask=%08x\n", str, val, fmask, *tmask); printf( "DecodeNumber- %s is %d fmask=%08x tmask=%08x\n", str, val, fmask, *tmask);
...@@ -3013,8 +3013,8 @@ printf( "DecodeNumber- misidentified year previously; swap with day %d\n", tm->t ...@@ -3013,8 +3013,8 @@ printf( "DecodeNumber- misidentified year previously; swap with day %d\n", tm->t
#endif #endif
tm->tm_mday = tm->tm_year; tm->tm_mday = tm->tm_year;
*tmask = DTK_M(DAY); *tmask = DTK_M(DAY);
}; }
}; }
tm->tm_year = val; tm->tm_year = val;
...@@ -3071,11 +3071,11 @@ printf( "DecodeNumber- (2) match %d (%s) as year\n", val, str); ...@@ -3071,11 +3071,11 @@ printf( "DecodeNumber- (2) match %d (%s) as year\n", val, str);
tm->tm_year += 2000; tm->tm_year += 2000;
} else if (tm->tm_year < 100) { } else if (tm->tm_year < 100) {
tm->tm_year += 1900; tm->tm_year += 1900;
}; }
} else { } else {
return -1; return -1;
}; }
return 0; return 0;
} /* DecodeNumber() */ } /* DecodeNumber() */
...@@ -3129,7 +3129,7 @@ printf( "DecodeNumberField- %s is date field fmask=%08x tmask=%08x\n", str, fmas ...@@ -3129,7 +3129,7 @@ printf( "DecodeNumberField- %s is date field fmask=%08x tmask=%08x\n", str, fmas
tm->tm_mon = atoi(str+2); tm->tm_mon = atoi(str+2);
*(str+2) = '\0'; *(str+2) = '\0';
tm->tm_year = atoi(str+0); tm->tm_year = atoi(str+0);
}; }
} else if (strchr(str,'.') != NULL) { } else if (strchr(str,'.') != NULL) {
#ifdef DATEDEBUG #ifdef DATEDEBUG
...@@ -3140,7 +3140,7 @@ printf( "DecodeNumberField- %s is time field fmask=%08x tmask=%08x\n", str, fmas ...@@ -3140,7 +3140,7 @@ printf( "DecodeNumberField- %s is time field fmask=%08x tmask=%08x\n", str, fmas
if (cp == (str+4)) return -1; if (cp == (str+4)) return -1;
if (*cp == '.') { if (*cp == '.') {
*fsec = strtod( cp, NULL); *fsec = strtod( cp, NULL);
}; }
*(str+4) = '\0'; *(str+4) = '\0';
tm->tm_min = strtod( (str+2), &cp); tm->tm_min = strtod( (str+2), &cp);
*(str+2) = '\0'; *(str+2) = '\0';
...@@ -3148,7 +3148,7 @@ printf( "DecodeNumberField- %s is time field fmask=%08x tmask=%08x\n", str, fmas ...@@ -3148,7 +3148,7 @@ printf( "DecodeNumberField- %s is time field fmask=%08x tmask=%08x\n", str, fmas
} else { } else {
return -1; return -1;
}; }
return 0; return 0;
} /* DecodeNumberField() */ } /* DecodeNumberField() */
...@@ -3180,7 +3180,7 @@ DecodeTimezone( char *str, int *tzp) ...@@ -3180,7 +3180,7 @@ DecodeTimezone( char *str, int *tzp)
} else { } else {
min = 0; min = 0;
}; }
tz = (hr*60+min)*60; tz = (hr*60+min)*60;
if (*str == '-') tz = -tz; if (*str == '-') tz = -tz;
...@@ -3209,7 +3209,7 @@ DecodeSpecial(int field, char *lowtoken, int *val) ...@@ -3209,7 +3209,7 @@ DecodeSpecial(int field, char *lowtoken, int *val)
#endif #endif
tp = datebsearch(lowtoken, datetktbl, szdatetktbl); tp = datebsearch(lowtoken, datetktbl, szdatetktbl);
#if USE_DATE_CACHE #if USE_DATE_CACHE
}; }
datecache[field] = tp; datecache[field] = tp;
#endif #endif
if (tp == NULL) { if (tp == NULL) {
...@@ -3227,8 +3227,8 @@ DecodeSpecial(int field, char *lowtoken, int *val) ...@@ -3227,8 +3227,8 @@ DecodeSpecial(int field, char *lowtoken, int *val)
default: default:
*val = tp->value; *val = tp->value;
break; break;
}; }
}; }
return(type); return(type);
} /* DecodeSpecial() */ } /* DecodeSpecial() */
...@@ -3278,8 +3278,8 @@ printf( "DecodeDateDelta- field[%d] is %s (type %d)\n", ii, field[ii], ftype[ii] ...@@ -3278,8 +3278,8 @@ printf( "DecodeDateDelta- field[%d] is %s (type %d)\n", ii, field[ii], ftype[ii]
} else { } else {
break; break;
}; }
}; }
/* read through remaining list backwards to pick up units before values */ /* read through remaining list backwards to pick up units before values */
for (i = nf-1; i >= ii; i--) { for (i = nf-1; i >= ii; i--) {
...@@ -3308,7 +3308,7 @@ printf( "DecodeDateDelta- field[%d] is %s (type %d)\n", i, field[i], ftype[i]); ...@@ -3308,7 +3308,7 @@ printf( "DecodeDateDelta- field[%d] is %s (type %d)\n", i, field[i], ftype[i]);
if (*cp == '.') { if (*cp == '.') {
*fsec = strtod( cp, NULL); *fsec = strtod( cp, NULL);
if (val < 0) *fsec = - (*fsec); if (val < 0) *fsec = - (*fsec);
}; }
flen = strlen(field[i]); flen = strlen(field[i]);
tmask = 0; /* DTK_M(type); */ tmask = 0; /* DTK_M(type); */
...@@ -3373,7 +3373,7 @@ printf( "DecodeDateDelta- field[%d] is %s (type %d)\n", i, field[i], ftype[i]); ...@@ -3373,7 +3373,7 @@ printf( "DecodeDateDelta- field[%d] is %s (type %d)\n", i, field[i], ftype[i]);
default: default:
return -1; return -1;
}; }
break; break;
case DTK_STRING: case DTK_STRING:
...@@ -3405,12 +3405,12 @@ printf( "DecodeDateDelta- UNITS field %s value is %d\n", field[i], val); ...@@ -3405,12 +3405,12 @@ printf( "DecodeDateDelta- UNITS field %s value is %d\n", field[i], val);
default: default:
return -1; return -1;
}; }
break; break;
default: default:
return -1; return -1;
}; }
#ifdef DATEDEBUG #ifdef DATEDEBUG
printf( "DecodeDateDelta- (%08x/%08x) field[%d] %s value is %d\n", printf( "DecodeDateDelta- (%08x/%08x) field[%d] %s value is %d\n",
...@@ -3419,12 +3419,12 @@ printf( "DecodeDateDelta- (%08x/%08x) field[%d] %s value is %d\n", ...@@ -3419,12 +3419,12 @@ printf( "DecodeDateDelta- (%08x/%08x) field[%d] %s value is %d\n",
if (tmask & fmask) return -1; if (tmask & fmask) return -1;
fmask |= tmask; fmask |= tmask;
}; }
if (*fsec != 0) { if (*fsec != 0) {
TMODULO(*fsec,sec,1); TMODULO(*fsec,sec,1);
tm->tm_sec += sec; tm->tm_sec += sec;
}; }
if (is_before) { if (is_before) {
*fsec = -(*fsec); *fsec = -(*fsec);
...@@ -3434,7 +3434,7 @@ printf( "DecodeDateDelta- (%08x/%08x) field[%d] %s value is %d\n", ...@@ -3434,7 +3434,7 @@ printf( "DecodeDateDelta- (%08x/%08x) field[%d] %s value is %d\n",
tm->tm_mday = -(tm->tm_mday); tm->tm_mday = -(tm->tm_mday);
tm->tm_mon = -(tm->tm_mon); tm->tm_mon = -(tm->tm_mon);
tm->tm_year = -(tm->tm_year); tm->tm_year = -(tm->tm_year);
}; }
#ifdef DATEDEBUG #ifdef DATEDEBUG
printf( "DecodeDateDelta- mask %08x (%08x)", fmask, DTK_DATE_M); printf( "DecodeDateDelta- mask %08x (%08x)", fmask, DTK_DATE_M);
...@@ -3465,7 +3465,7 @@ DecodeUnits(int field, char *lowtoken, int *val) ...@@ -3465,7 +3465,7 @@ DecodeUnits(int field, char *lowtoken, int *val)
#endif #endif
tp = datebsearch(lowtoken, deltatktbl, szdeltatktbl); tp = datebsearch(lowtoken, deltatktbl, szdeltatktbl);
#if USE_DATE_CACHE #if USE_DATE_CACHE
}; }
deltacache[field] = tp; deltacache[field] = tp;
#endif #endif
if (tp == NULL) { if (tp == NULL) {
...@@ -3477,8 +3477,8 @@ DecodeUnits(int field, char *lowtoken, int *val) ...@@ -3477,8 +3477,8 @@ DecodeUnits(int field, char *lowtoken, int *val)
*val = FROMVAL(tp); *val = FROMVAL(tp);
} else { } else {
*val = tp->value; *val = tp->value;
}; }
}; }
return(type); return(type);
} /* DecodeUnits() */ } /* DecodeUnits() */
...@@ -3538,9 +3538,9 @@ EncodeSpecialDateTime(DateTime dt, char *str) ...@@ -3538,9 +3538,9 @@ EncodeSpecialDateTime(DateTime dt, char *str)
printf( "EncodeSpecialDateTime- unrecognized date\n"); printf( "EncodeSpecialDateTime- unrecognized date\n");
#endif #endif
strcpy( str, INVALID); strcpy( str, INVALID);
}; }
return(TRUE); return(TRUE);
}; }
return(FALSE); return(FALSE);
} /* EncodeSpecialDateTime() */ } /* EncodeSpecialDateTime() */
...@@ -3567,7 +3567,7 @@ int EncodeDateOnly(struct tm *tm, int style, char *str) ...@@ -3567,7 +3567,7 @@ int EncodeDateOnly(struct tm *tm, int style, char *str)
} else { } else {
sprintf( str, "%04d-%02d-%02d %s", sprintf( str, "%04d-%02d-%02d %s",
-(tm->tm_year-1), tm->tm_mon, tm->tm_mday, "BC"); -(tm->tm_year-1), tm->tm_mon, tm->tm_mday, "BC");
}; }
/* compatible with Oracle/Ingres date formats */ /* compatible with Oracle/Ingres date formats */
} else if (style == USE_SQL_DATES) { } else if (style == USE_SQL_DATES) {
...@@ -3575,13 +3575,13 @@ int EncodeDateOnly(struct tm *tm, int style, char *str) ...@@ -3575,13 +3575,13 @@ int EncodeDateOnly(struct tm *tm, int style, char *str)
sprintf( str, "%02d/%02d", tm->tm_mday, tm->tm_mon); sprintf( str, "%02d/%02d", tm->tm_mday, tm->tm_mon);
} else { } else {
sprintf( str, "%02d/%02d", tm->tm_mon, tm->tm_mday); sprintf( str, "%02d/%02d", tm->tm_mon, tm->tm_mday);
}; }
if (tm->tm_year > 0) { if (tm->tm_year > 0) {
sprintf( (str+5), "/%04d", tm->tm_year); sprintf( (str+5), "/%04d", tm->tm_year);
} else { } else {
sprintf( (str+5), "/%04d %s", -(tm->tm_year-1), "BC"); sprintf( (str+5), "/%04d %s", -(tm->tm_year-1), "BC");
}; }
/* backward-compatible with traditional Postgres abstime dates */ /* backward-compatible with traditional Postgres abstime dates */
} else { /* if (style == USE_POSTGRES_DATES) */ } else { /* if (style == USE_POSTGRES_DATES) */
...@@ -3600,13 +3600,13 @@ printf( "EncodeDateOnly- day is %d\n", day); ...@@ -3600,13 +3600,13 @@ printf( "EncodeDateOnly- day is %d\n", day);
sprintf( (str+4), "%02d %3s", tm->tm_mday, months[tm->tm_mon-1]); sprintf( (str+4), "%02d %3s", tm->tm_mday, months[tm->tm_mon-1]);
} else { } else {
sprintf( (str+4), "%3s %02d", months[tm->tm_mon-1], tm->tm_mday); sprintf( (str+4), "%3s %02d", months[tm->tm_mon-1], tm->tm_mday);
}; }
if (tm->tm_year > 0) { if (tm->tm_year > 0) {
sprintf( (str+10), " %04d", tm->tm_year); sprintf( (str+10), " %04d", tm->tm_year);
} else { } else {
sprintf( (str+10), " %04d %s", -(tm->tm_year-1), "BC"); sprintf( (str+10), " %04d %s", -(tm->tm_year-1), "BC");
}; }
#endif #endif
/* traditional date-only style for Postgres */ /* traditional date-only style for Postgres */
...@@ -3614,14 +3614,14 @@ printf( "EncodeDateOnly- day is %d\n", day); ...@@ -3614,14 +3614,14 @@ printf( "EncodeDateOnly- day is %d\n", day);
sprintf( str, "%02d-%02d", tm->tm_mday, tm->tm_mon); sprintf( str, "%02d-%02d", tm->tm_mday, tm->tm_mon);
} else { } else {
sprintf( str, "%02d-%02d", tm->tm_mon, tm->tm_mday); sprintf( str, "%02d-%02d", tm->tm_mon, tm->tm_mday);
}; }
if (tm->tm_year > 0) { if (tm->tm_year > 0) {
sprintf( (str+5), "-%04d", tm->tm_year); sprintf( (str+5), "-%04d", tm->tm_year);
} else { } else {
sprintf( (str+5), "-%04d %s", -(tm->tm_year-1), "BC"); sprintf( (str+5), "-%04d %s", -(tm->tm_year-1), "BC");
}; }
}; }
#ifdef DATEDEBUG #ifdef DATEDEBUG
printf( "EncodeDateOnly- date result is %s\n", str); printf( "EncodeDateOnly- date result is %s\n", str);
...@@ -3696,9 +3696,9 @@ printf( "EncodeDateTime- timezone is %s (%s); offset is %d; daylight is %d\n", ...@@ -3696,9 +3696,9 @@ printf( "EncodeDateTime- timezone is %s (%s); offset is %d; daylight is %d\n",
} else { } else {
hour = 0; hour = 0;
min = 0; min = 0;
}; }
sprintf( (str+strlen(str)), ((min != 0)? "%+03d:%02d": "%+03d"), hour, min); sprintf( (str+strlen(str)), ((min != 0)? "%+03d:%02d": "%+03d"), hour, min);
}; }
} else { } else {
if (tm->tm_hour || tm->tm_min) { if (tm->tm_hour || tm->tm_min) {
...@@ -3707,8 +3707,8 @@ printf( "EncodeDateTime- timezone is %s (%s); offset is %d; daylight is %d\n", ...@@ -3707,8 +3707,8 @@ printf( "EncodeDateTime- timezone is %s (%s); offset is %d; daylight is %d\n",
} else { } else {
sprintf( str, "%04d-%02d-%02d %s", sprintf( str, "%04d-%02d-%02d %s",
-(tm->tm_year-1), tm->tm_mon, tm->tm_mday, "BC"); -(tm->tm_year-1), tm->tm_mon, tm->tm_mday, "BC");
}; }
}; }
/* compatible with Oracle/Ingres date formats */ /* compatible with Oracle/Ingres date formats */
} else if (style == USE_SQL_DATES) { } else if (style == USE_SQL_DATES) {
...@@ -3716,7 +3716,7 @@ printf( "EncodeDateTime- timezone is %s (%s); offset is %d; daylight is %d\n", ...@@ -3716,7 +3716,7 @@ printf( "EncodeDateTime- timezone is %s (%s); offset is %d; daylight is %d\n",
sprintf( str, "%02d/%02d", tm->tm_mday, tm->tm_mon); sprintf( str, "%02d/%02d", tm->tm_mday, tm->tm_mon);
} else { } else {
sprintf( str, "%02d/%02d", tm->tm_mon, tm->tm_mday); sprintf( str, "%02d/%02d", tm->tm_mon, tm->tm_mday);
}; }
if (tm->tm_year > 0) { if (tm->tm_year > 0) {
sprintf( (str+5), "/%04d %02d:%02d:%05.2f", sprintf( (str+5), "/%04d %02d:%02d:%05.2f",
tm->tm_year, tm->tm_hour, tm->tm_min, sec); tm->tm_year, tm->tm_hour, tm->tm_min, sec);
...@@ -3724,12 +3724,12 @@ printf( "EncodeDateTime- timezone is %s (%s); offset is %d; daylight is %d\n", ...@@ -3724,12 +3724,12 @@ printf( "EncodeDateTime- timezone is %s (%s); offset is %d; daylight is %d\n",
if ((*tzn != NULL) && (tm->tm_isdst >= 0)) { if ((*tzn != NULL) && (tm->tm_isdst >= 0)) {
strcpy( (str+22), " "); strcpy( (str+22), " ");
strcpy( (str+23), *tzn); strcpy( (str+23), *tzn);
}; }
} else { } else {
sprintf( (str+5), "/%04d %02d:%02d %s", sprintf( (str+5), "/%04d %02d:%02d %s",
-(tm->tm_year-1), tm->tm_hour, tm->tm_min, "BC"); -(tm->tm_year-1), tm->tm_hour, tm->tm_min, "BC");
}; }
/* backward-compatible with traditional Postgres abstime dates */ /* backward-compatible with traditional Postgres abstime dates */
} else { /* if (style == USE_POSTGRES_DATES) */ } else { /* if (style == USE_POSTGRES_DATES) */
...@@ -3746,7 +3746,7 @@ printf( "EncodeDateTime- day is %d\n", day); ...@@ -3746,7 +3746,7 @@ printf( "EncodeDateTime- day is %d\n", day);
sprintf( (str+4), "%02d %3s", tm->tm_mday, months[tm->tm_mon-1]); sprintf( (str+4), "%02d %3s", tm->tm_mday, months[tm->tm_mon-1]);
} else { } else {
sprintf( (str+4), "%3s %02d", months[tm->tm_mon-1], tm->tm_mday); sprintf( (str+4), "%3s %02d", months[tm->tm_mon-1], tm->tm_mday);
}; }
if (tm->tm_year > 0) { if (tm->tm_year > 0) {
sprintf( (str+10), " %02d:%02d", tm->tm_hour, tm->tm_min); sprintf( (str+10), " %02d:%02d", tm->tm_hour, tm->tm_min);
if (fsec != 0) { if (fsec != 0) {
...@@ -3754,20 +3754,20 @@ printf( "EncodeDateTime- day is %d\n", day); ...@@ -3754,20 +3754,20 @@ printf( "EncodeDateTime- day is %d\n", day);
if ((*tzn != NULL) && (tm->tm_isdst >= 0)) { if ((*tzn != NULL) && (tm->tm_isdst >= 0)) {
strcpy( (str+27), " "); strcpy( (str+27), " ");
strcpy( (str+28), *tzn); strcpy( (str+28), *tzn);
}; }
} else { } else {
sprintf( (str+16), ":%02.0f %04d", sec, tm->tm_year); sprintf( (str+16), ":%02.0f %04d", sec, tm->tm_year);
if ((*tzn != NULL) && (tm->tm_isdst >= 0)) { if ((*tzn != NULL) && (tm->tm_isdst >= 0)) {
strcpy( (str+24), " "); strcpy( (str+24), " ");
strcpy( (str+25), *tzn); strcpy( (str+25), *tzn);
}; }
}; }
} else { } else {
sprintf( (str+10), " %02d:%02d %04d %s", sprintf( (str+10), " %02d:%02d %04d %s",
tm->tm_hour, tm->tm_min, -(tm->tm_year-1), "BC"); tm->tm_hour, tm->tm_min, -(tm->tm_year-1), "BC");
}; }
}; }
#ifdef DATEDEBUG #ifdef DATEDEBUG
printf( "EncodeDateTime- date result is %s\n", str); printf( "EncodeDateTime- date result is %s\n", str);
...@@ -3797,35 +3797,35 @@ int EncodeTimeSpan(struct tm *tm, double fsec, int style, char *str) ...@@ -3797,35 +3797,35 @@ int EncodeTimeSpan(struct tm *tm, double fsec, int style, char *str)
is_before |= (tm->tm_year < 0); is_before |= (tm->tm_year < 0);
sprintf( cp, " %d year%s", abs(tm->tm_year), ((abs(tm->tm_year) != 1)? "s": "")); sprintf( cp, " %d year%s", abs(tm->tm_year), ((abs(tm->tm_year) != 1)? "s": ""));
cp += strlen(cp); cp += strlen(cp);
}; }
if (tm->tm_mon != 0) { if (tm->tm_mon != 0) {
is_nonzero = TRUE; is_nonzero = TRUE;
is_before |= (tm->tm_mon < 0); is_before |= (tm->tm_mon < 0);
sprintf( cp, " %d mon%s", abs(tm->tm_mon), ((abs(tm->tm_mon) != 1)? "s": "")); sprintf( cp, " %d mon%s", abs(tm->tm_mon), ((abs(tm->tm_mon) != 1)? "s": ""));
cp += strlen(cp); cp += strlen(cp);
}; }
if (tm->tm_mday != 0) { if (tm->tm_mday != 0) {
is_nonzero = TRUE; is_nonzero = TRUE;
is_before |= (tm->tm_mday < 0); is_before |= (tm->tm_mday < 0);
sprintf( cp, " %d day%s", abs(tm->tm_mday), ((abs(tm->tm_mday) != 1)? "s": "")); sprintf( cp, " %d day%s", abs(tm->tm_mday), ((abs(tm->tm_mday) != 1)? "s": ""));
cp += strlen(cp); cp += strlen(cp);
}; }
if (tm->tm_hour != 0) { if (tm->tm_hour != 0) {
is_nonzero = TRUE; is_nonzero = TRUE;
is_before |= (tm->tm_hour < 0); is_before |= (tm->tm_hour < 0);
sprintf( cp, " %d hour%s", abs(tm->tm_hour), ((abs(tm->tm_hour) != 1)? "s": "")); sprintf( cp, " %d hour%s", abs(tm->tm_hour), ((abs(tm->tm_hour) != 1)? "s": ""));
cp += strlen(cp); cp += strlen(cp);
}; }
if (tm->tm_min != 0) { if (tm->tm_min != 0) {
is_nonzero = TRUE; is_nonzero = TRUE;
is_before |= (tm->tm_min < 0); is_before |= (tm->tm_min < 0);
sprintf( cp, " %d min%s", abs(tm->tm_min), ((abs(tm->tm_min) != 1)? "s": "")); sprintf( cp, " %d min%s", abs(tm->tm_min), ((abs(tm->tm_min) != 1)? "s": ""));
cp += strlen(cp); cp += strlen(cp);
}; }
/* fractional seconds? */ /* fractional seconds? */
if (fsec != 0) { if (fsec != 0) {
...@@ -3841,18 +3841,18 @@ int EncodeTimeSpan(struct tm *tm, double fsec, int style, char *str) ...@@ -3841,18 +3841,18 @@ int EncodeTimeSpan(struct tm *tm, double fsec, int style, char *str)
is_before |= (tm->tm_sec < 0); is_before |= (tm->tm_sec < 0);
sprintf( cp, " %d sec%s", abs(tm->tm_sec), ((abs(tm->tm_sec) != 1)? "s": "")); sprintf( cp, " %d sec%s", abs(tm->tm_sec), ((abs(tm->tm_sec) != 1)? "s": ""));
cp += strlen(cp); cp += strlen(cp);
}; }
/* identically zero? then put in a unitless zero... */ /* identically zero? then put in a unitless zero... */
if (! is_nonzero) { if (! is_nonzero) {
strcat( cp, " 0"); strcat( cp, " 0");
cp += strlen(cp); cp += strlen(cp);
}; }
if (is_before) { if (is_before) {
strcat( cp, " ago"); strcat( cp, " ago");
cp += strlen(cp); cp += strlen(cp);
}; }
#ifdef DATEDEBUG #ifdef DATEDEBUG
printf( "EncodeTimeSpan- result is %s\n", str); printf( "EncodeTimeSpan- result is %s\n", str);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.16 1997/08/21 23:56:41 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.17 1997/09/05 18:11:14 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -158,7 +158,7 @@ static int pair_decode(char *str, float8 *x, float8 *y, char **s) ...@@ -158,7 +158,7 @@ static int pair_decode(char *str, float8 *x, float8 *y, char **s)
if (*str != RDELIM) return(FALSE); if (*str != RDELIM) return(FALSE);
str++; str++;
while (isspace( *str)) str++; while (isspace( *str)) str++;
}; }
if (s != NULL) *s = str; if (s != NULL) *s = str;
return(TRUE); return(TRUE);
...@@ -196,8 +196,8 @@ static int path_decode(int opentype, int npts, char *str, int *isopen, char **ss ...@@ -196,8 +196,8 @@ static int path_decode(int opentype, int npts, char *str, int *isopen, char **ss
} else if (strrchr( s, LDELIM) == s) { } else if (strrchr( s, LDELIM) == s) {
depth++; depth++;
s = cp; s = cp;
}; }
}; }
for (i = 0; i < npts; i++) { for (i = 0; i < npts; i++) {
if (! pair_decode( s, &(p->x), &(p->y), &s)) if (! pair_decode( s, &(p->x), &(p->y), &s))
...@@ -205,7 +205,7 @@ static int path_decode(int opentype, int npts, char *str, int *isopen, char **ss ...@@ -205,7 +205,7 @@ static int path_decode(int opentype, int npts, char *str, int *isopen, char **ss
if (*s == DELIM) s++; if (*s == DELIM) s++;
p++; p++;
}; }
while (depth > 0) { while (depth > 0) {
if ((*s == RDELIM) if ((*s == RDELIM)
...@@ -215,8 +215,8 @@ static int path_decode(int opentype, int npts, char *str, int *isopen, char **ss ...@@ -215,8 +215,8 @@ static int path_decode(int opentype, int npts, char *str, int *isopen, char **ss
while (isspace( *s)) s++; while (isspace( *s)) s++;
} else { } else {
return(FALSE); return(FALSE);
}; }
}; }
*ss = s; *ss = s;
return(TRUE); return(TRUE);
...@@ -239,7 +239,7 @@ static char *path_encode( bool closed, int npts, Point *pt) ...@@ -239,7 +239,7 @@ static char *path_encode( bool closed, int npts, Point *pt)
break; break;
default: default:
break; break;
}; }
for (i = 0; i < npts; i++) { for (i = 0; i < npts; i++) {
*cp++ = LDELIM; *cp++ = LDELIM;
...@@ -249,7 +249,7 @@ static char *path_encode( bool closed, int npts, Point *pt) ...@@ -249,7 +249,7 @@ static char *path_encode( bool closed, int npts, Point *pt)
*cp++ = RDELIM; *cp++ = RDELIM;
*cp++ = DELIM; *cp++ = DELIM;
pt++; pt++;
}; }
cp--; cp--;
switch (closed) { switch (closed) {
case TRUE: case TRUE:
...@@ -260,7 +260,7 @@ static char *path_encode( bool closed, int npts, Point *pt) ...@@ -260,7 +260,7 @@ static char *path_encode( bool closed, int npts, Point *pt)
break; break;
default: default:
break; break;
}; }
*cp = '\0'; *cp = '\0';
return(result); return(result);
...@@ -280,7 +280,7 @@ static int pair_count(char *s, char delim) ...@@ -280,7 +280,7 @@ static int pair_count(char *s, char delim)
while ((s = strchr( s, delim)) != NULL) { while ((s = strchr( s, delim)) != NULL) {
ndelim++; ndelim++;
s++; s++;
}; }
return((ndelim % 2)? ((ndelim+1)/2): -1); return((ndelim % 2)? ((ndelim+1)/2): -1);
} }
...@@ -320,12 +320,12 @@ BOX *box_in(char *str) ...@@ -320,12 +320,12 @@ BOX *box_in(char *str)
x = box->high.x; x = box->high.x;
box->high.x = box->low.x; box->high.x = box->low.x;
box->low.x = x; box->low.x = x;
}; }
if (box->high.y < box->low.y) { if (box->high.y < box->low.y) {
y = box->high.y; y = box->high.y;
box->high.y = box->low.y; box->high.y = box->low.y;
box->low.y = y; box->low.y = y;
}; }
return(box); return(box);
} /* box_in() */ } /* box_in() */
...@@ -361,14 +361,14 @@ static BOX *box_fill(BOX *result, double x1, double x2, double y1, double y2) ...@@ -361,14 +361,14 @@ static BOX *box_fill(BOX *result, double x1, double x2, double y1, double y2)
} else { } else {
result->high.x = x2; result->high.x = x2;
result->low.x = x1; result->low.x = x1;
}; }
if (y1 > y2) { if (y1 > y2) {
result->high.y = y1; result->high.y = y1;
result->low.y = y2; result->low.y = y2;
} else { } else {
result->high.y = y2; result->high.y = y2;
result->low.y = y1; result->low.y = y1;
}; }
return(result); return(result);
} }
...@@ -739,7 +739,7 @@ printf( "line_construct_pp- line is neither vertical nor horizontal (diffs x=%.* ...@@ -739,7 +739,7 @@ printf( "line_construct_pp- line is neither vertical nor horizontal (diffs x=%.*
digits8, (pt2->x - pt1->x), digits8, (pt2->y - pt1->y)); digits8, (pt2->x - pt1->x), digits8, (pt2->y - pt1->y));
#endif #endif
result->m = result->A; result->m = result->A;
}; }
return(result); return(result);
} /* line_construct_pp() */ } /* line_construct_pp() */
...@@ -760,7 +760,7 @@ static bool line_parallel(LINE *l1, LINE *l2) ...@@ -760,7 +760,7 @@ static bool line_parallel(LINE *l1, LINE *l2)
#endif #endif
if (FPzero(l1->B)) { if (FPzero(l1->B)) {
return(FPzero(l2->B)); return(FPzero(l2->B));
}; }
return(FPeq(l2->A, l1->A*(l2->B / l1->B))); return(FPeq(l2->A, l1->A*(l2->B / l1->B)));
} /* line_parallel() */ } /* line_parallel() */
...@@ -778,7 +778,7 @@ bool line_perp(LINE *l1, LINE *l2) ...@@ -778,7 +778,7 @@ bool line_perp(LINE *l1, LINE *l2)
return( FPzero(l2->B) ); return( FPzero(l2->B) );
} else if (FPzero(l1->B)) { } else if (FPzero(l1->B)) {
return( FPzero(l2->A) ); return( FPzero(l2->A) );
}; }
return( FPeq(((l1->A * l2->B) / (l1->B * l2->A)), -1.0) ); return( FPeq(((l1->A * l2->B) / (l1->B * l2->A)), -1.0) );
} /* line_perp() */ } /* line_perp() */
...@@ -889,7 +889,7 @@ line_interpt(LINE *l1, LINE *l2) ...@@ -889,7 +889,7 @@ line_interpt(LINE *l1, LINE *l2)
#endif #endif
x = (l1->C - l2->C) / (l2->A - l1->A); x = (l1->C - l2->C) / (l2->A - l1->A);
y = (l1->A * x + l1->C); y = (l1->A * x + l1->C);
}; }
result = point_construct(x, y); result = point_construct(x, y);
#ifdef GEODEBUG #ifdef GEODEBUG
...@@ -946,7 +946,7 @@ PATH *path_in(char *str) ...@@ -946,7 +946,7 @@ PATH *path_in(char *str)
if ((*s == LDELIM) && (strrchr( s, LDELIM) == s)) { if ((*s == LDELIM) && (strrchr( s, LDELIM) == s)) {
s++; s++;
depth++; depth++;
}; }
size = offsetof(PATH, p[0]) + (sizeof(path->p[0]) * npts); size = offsetof(PATH, p[0]) + (sizeof(path->p[0]) * npts);
path = PALLOC(size); path = PALLOC(size);
...@@ -1153,7 +1153,7 @@ double *path_distance(PATH *p1, PATH *p2) ...@@ -1153,7 +1153,7 @@ double *path_distance(PATH *p1, PATH *p2)
min = tmp; min = tmp;
} else { } else {
PFREE(tmp); PFREE(tmp);
}; }
} }
return(min); return(min);
...@@ -1593,12 +1593,12 @@ lseg_interpt(LSEG *l1, LSEG *l2) ...@@ -1593,12 +1593,12 @@ lseg_interpt(LSEG *l1, LSEG *l2)
|| (FPeq( l1->p[1].x, l2->p[1].x) && FPeq( l1->p[1].y, l2->p[1].y))) { || (FPeq( l1->p[1].x, l2->p[1].x) && FPeq( l1->p[1].y, l2->p[1].y))) {
result->x = l1->p[1].x; result->x = l1->p[1].x;
result->y = l1->p[1].y; result->y = l1->p[1].y;
}; }
} else { } else {
PFREE(result); PFREE(result);
result = NULL; result = NULL;
}; }
}; }
PFREE(tmp1); PFREE(tmp1);
PFREE(tmp2); PFREE(tmp2);
...@@ -1653,7 +1653,7 @@ double *dist_ps(Point *pt, LSEG *lseg) ...@@ -1653,7 +1653,7 @@ double *dist_ps(Point *pt, LSEG *lseg)
(lseg->p[1].x - lseg->p[0].x); (lseg->p[1].x - lseg->p[0].x);
#endif #endif
m = ((lseg->p[0].y - lseg->p[1].y) / (lseg->p[1].x - lseg->p[0].x)); m = ((lseg->p[0].y - lseg->p[1].y) / (lseg->p[1].x - lseg->p[0].x));
}; }
ln = line_construct_pm(pt, m); ln = line_construct_pm(pt, m);
#ifdef GEODEBUG #ifdef GEODEBUG
...@@ -1680,7 +1680,7 @@ printf( "dist_ps- distance is %f to intersection point is (%f,%f)\n", ...@@ -1680,7 +1680,7 @@ printf( "dist_ps- distance is %f to intersection point is (%f,%f)\n",
tmpdist = point_distance(pt, &lseg->p[1]); tmpdist = point_distance(pt, &lseg->p[1]);
if (*tmpdist < *result) *result = *tmpdist; if (*tmpdist < *result) *result = *tmpdist;
PFREE (tmpdist); PFREE (tmpdist);
}; }
if (ip != NULL) PFREE(ip); if (ip != NULL) PFREE(ip);
PFREE(ln); PFREE(ln);
...@@ -1756,8 +1756,8 @@ double *dist_sl(LSEG *lseg, LINE *line) ...@@ -1756,8 +1756,8 @@ double *dist_sl(LSEG *lseg, LINE *line)
result = d2; result = d2;
} else { } else {
PFREE( d2); PFREE( d2);
}; }
}; }
return(result); return(result);
} }
...@@ -1818,7 +1818,7 @@ printf( "dist_cpoly- center inside of polygon\n"); ...@@ -1818,7 +1818,7 @@ printf( "dist_cpoly- center inside of polygon\n");
*result = 0; *result = 0;
return(result); return(result);
}; }
/* initialize distance with segment between first and last points */ /* initialize distance with segment between first and last points */
seg.p[0].x = poly->p[0].x; seg.p[0].x = poly->p[0].x;
...@@ -1842,7 +1842,7 @@ printf( "dist_cpoly- segment %d distance is %f\n", (i+1), *d); ...@@ -1842,7 +1842,7 @@ printf( "dist_cpoly- segment %d distance is %f\n", (i+1), *d);
#endif #endif
if (*d < *result) *result = *d; if (*d < *result) *result = *d;
PFREE(d); PFREE(d);
}; }
*result -= circle->radius; *result -= circle->radius;
if (*result < 0) *result = 0; if (*result < 0) *result = 0;
...@@ -1883,8 +1883,8 @@ printf( "interpt_sl- intersection point is on segment\n"); ...@@ -1883,8 +1883,8 @@ printf( "interpt_sl- intersection point is on segment\n");
} else { } else {
PFREE(p); PFREE(p);
p = NULL; p = NULL;
}; }
}; }
PFREE(tmp); PFREE(tmp);
return(p); return(p);
...@@ -2232,12 +2232,12 @@ static void make_bound_box(POLYGON *poly) ...@@ -2232,12 +2232,12 @@ static void make_bound_box(POLYGON *poly)
if (poly->p[i].x > x2) x2 = poly->p[i].x; if (poly->p[i].x > x2) x2 = poly->p[i].x;
if (poly->p[i].y < y1) y1 = poly->p[i].y; if (poly->p[i].y < y1) y1 = poly->p[i].y;
if (poly->p[i].y > y2) y2 = poly->p[i].y; if (poly->p[i].y > y2) y2 = poly->p[i].y;
}; }
box_fill(&(poly->boundbox), x1, x2, y1, y2); box_fill(&(poly->boundbox), x1, x2, y1, y2);
} else { } else {
elog (WARN, "Unable to create bounding box for empty polygon", NULL); elog (WARN, "Unable to create bounding box for empty polygon", NULL);
}; }
} }
/*------------------------------------------------------------------ /*------------------------------------------------------------------
...@@ -2354,7 +2354,7 @@ bool poly_same(POLYGON *polya, POLYGON *polyb) ...@@ -2354,7 +2354,7 @@ bool poly_same(POLYGON *polya, POLYGON *polyb)
if ((polya->p[i].x != polyb->p[i].x) if ((polya->p[i].x != polyb->p[i].x)
|| (polya->p[i].y != polyb->p[i].y)) || (polya->p[i].y != polyb->p[i].y))
return FALSE; return FALSE;
}; }
return TRUE; return TRUE;
#endif #endif
} /* poly_same() */ } /* poly_same() */
...@@ -2395,18 +2395,18 @@ poly_contain(POLYGON *polya, POLYGON *polyb) ...@@ -2395,18 +2395,18 @@ poly_contain(POLYGON *polya, POLYGON *polyb)
printf( "poly_contain- point (%f,%f) not in polygon\n", polyb->p[i].x, polyb->p[i].y); printf( "poly_contain- point (%f,%f) not in polygon\n", polyb->p[i].x, polyb->p[i].y);
#endif #endif
return(FALSE); return(FALSE);
}; }
}; }
for (i = 0; i < polya->npts; i++) { for (i = 0; i < polya->npts; i++) {
if (point_inside(&(polya->p[i]), polyb->npts, &(polyb->p[0])) == 1) { if (point_inside(&(polya->p[i]), polyb->npts, &(polyb->p[0])) == 1) {
#if GEODEBUG #if GEODEBUG
printf( "poly_contain- point (%f,%f) in polygon\n", polya->p[i].x, polya->p[i].y); printf( "poly_contain- point (%f,%f) in polygon\n", polya->p[i].x, polya->p[i].y);
#endif #endif
return(FALSE); return(FALSE);
}; }
}; }
return(TRUE); return(TRUE);
}; }
#if GEODEBUG #if GEODEBUG
printf( "poly_contain- bound box ((%f,%f),(%f,%f)) not inside ((%f,%f),(%f,%f))\n", printf( "poly_contain- bound box ((%f,%f),(%f,%f)) not inside ((%f,%f),(%f,%f))\n",
polyb->boundbox.low.x,polyb->boundbox.low.y,polyb->boundbox.high.x,polyb->boundbox.high.y, polyb->boundbox.low.x,polyb->boundbox.low.y,polyb->boundbox.high.x,polyb->boundbox.high.y,
...@@ -2691,11 +2691,11 @@ path_add(PATH *p1, PATH *p2) ...@@ -2691,11 +2691,11 @@ path_add(PATH *p1, PATH *p2)
for (i=0; i<p1->npts; i++) { for (i=0; i<p1->npts; i++) {
result->p[i].x = p1->p[i].x; result->p[i].x = p1->p[i].x;
result->p[i].y = p1->p[i].y; result->p[i].y = p1->p[i].y;
}; }
for (i=0; i<p2->npts; i++) { for (i=0; i<p2->npts; i++) {
result->p[i+p1->npts].x = p2->p[i].x; result->p[i+p1->npts].x = p2->p[i].x;
result->p[i+p1->npts].y = p2->p[i].y; result->p[i+p1->npts].y = p2->p[i].y;
}; }
return(result); return(result);
} /* path_add() */ } /* path_add() */
...@@ -2717,7 +2717,7 @@ path_add_pt(PATH *path, Point *point) ...@@ -2717,7 +2717,7 @@ path_add_pt(PATH *path, Point *point)
for (i=0; i<path->npts; i++) { for (i=0; i<path->npts; i++) {
result->p[i].x += point->x; result->p[i].x += point->x;
result->p[i].y += point->y; result->p[i].y += point->y;
}; }
return(result); return(result);
} /* path_add_pt() */ } /* path_add_pt() */
...@@ -2736,7 +2736,7 @@ path_sub_pt(PATH *path, Point *point) ...@@ -2736,7 +2736,7 @@ path_sub_pt(PATH *path, Point *point)
for (i=0; i<path->npts; i++) { for (i=0; i<path->npts; i++) {
result->p[i].x -= point->x; result->p[i].x -= point->x;
result->p[i].y -= point->y; result->p[i].y -= point->y;
}; }
return(result); return(result);
} /* path_sub_pt() */ } /* path_sub_pt() */
...@@ -2762,7 +2762,7 @@ path_mul_pt(PATH *path, Point *point) ...@@ -2762,7 +2762,7 @@ path_mul_pt(PATH *path, Point *point)
result->p[i].x = p->x; result->p[i].x = p->x;
result->p[i].y = p->y; result->p[i].y = p->y;
PFREE(p); PFREE(p);
}; }
return(result); return(result);
} /* path_mul_pt() */ } /* path_mul_pt() */
...@@ -2784,7 +2784,7 @@ path_div_pt(PATH *path, Point *point) ...@@ -2784,7 +2784,7 @@ path_div_pt(PATH *path, Point *point)
result->p[i].x = p->x; result->p[i].x = p->x;
result->p[i].y = p->y; result->p[i].y = p->y;
PFREE(p); PFREE(p);
}; }
return(result); return(result);
} /* path_div_pt() */ } /* path_div_pt() */
...@@ -2846,7 +2846,7 @@ POLYGON *path_poly(PATH *path) ...@@ -2846,7 +2846,7 @@ POLYGON *path_poly(PATH *path)
for (i=0; i<path->npts; i++) { for (i=0; i<path->npts; i++) {
poly->p[i].x = path->p[i].x; poly->p[i].x = path->p[i].x;
poly->p[i].y = path->p[i].y; poly->p[i].y = path->p[i].y;
}; }
make_bound_box(poly); make_bound_box(poly);
...@@ -2886,7 +2886,7 @@ PATH ...@@ -2886,7 +2886,7 @@ PATH
for (i=0; i<result->npts; i++) { for (i=0; i<result->npts; i++) {
result->p[i].x = path->p[i+1].x; result->p[i].x = path->p[i+1].x;
result->p[i].y = path->p[i+1].y; result->p[i].y = path->p[i+1].y;
}; }
return(result); return(result);
} /* upgradepath() */ } /* upgradepath() */
...@@ -2932,7 +2932,7 @@ poly_center(POLYGON *poly) ...@@ -2932,7 +2932,7 @@ poly_center(POLYGON *poly)
} else { } else {
result = NULL; result = NULL;
}; }
return(result); return(result);
} /* poly_center() */ } /* poly_center() */
...@@ -3006,7 +3006,7 @@ poly_path(POLYGON *poly) ...@@ -3006,7 +3006,7 @@ poly_path(POLYGON *poly)
for (i=0; i<poly->npts; i++) { for (i=0; i<poly->npts; i++) {
path->p[i].x = poly->p[i].x; path->p[i].x = poly->p[i].x;
path->p[i].y = poly->p[i].y; path->p[i].y = poly->p[i].y;
}; }
return(path); return(path);
} /* poly_path() */ } /* poly_path() */
...@@ -3039,17 +3039,17 @@ POLYGON ...@@ -3039,17 +3039,17 @@ POLYGON
for (i=0; i<n2; i++) { for (i=0; i<n2; i++) {
result->p[2*i].x = poly->p[i].x; /* even indices */ result->p[2*i].x = poly->p[i].x; /* even indices */
result->p[2*i+1].x = poly->p[i].y; /* odd indices */ result->p[2*i+1].x = poly->p[i].y; /* odd indices */
}; }
if ((ii = ((poly->npts % 2)? 1: 0))) { if ((ii = ((poly->npts % 2)? 1: 0))) {
result->p[poly->npts-1].x = poly->p[n2].x; result->p[poly->npts-1].x = poly->p[n2].x;
result->p[0].y = poly->p[n2].y; result->p[0].y = poly->p[n2].y;
}; }
for (i=0; i<n2; i++) { for (i=0; i<n2; i++) {
result->p[2*i+ii].y = poly->p[i+n2+ii].x; /* even (+offset) indices */ result->p[2*i+ii].y = poly->p[i+n2+ii].x; /* even (+offset) indices */
result->p[2*i+ii+1].y = poly->p[i+n2+ii].y; /* odd (+offset) indices */ result->p[2*i+ii+1].y = poly->p[i+n2+ii].y; /* odd (+offset) indices */
}; }
return(result); return(result);
} /* upgradepoly() */ } /* upgradepoly() */
...@@ -3079,17 +3079,17 @@ POLYGON ...@@ -3079,17 +3079,17 @@ POLYGON
for (i=0; i<n2; i++) { for (i=0; i<n2; i++) {
result->p[i].x = poly->p[2*i].x; /* even indices */ result->p[i].x = poly->p[2*i].x; /* even indices */
result->p[i].y = poly->p[2*i+1].x; /* odd indices */ result->p[i].y = poly->p[2*i+1].x; /* odd indices */
}; }
if ((ii = ((poly->npts % 2)? 1: 0))) { if ((ii = ((poly->npts % 2)? 1: 0))) {
result->p[n2].x = poly->p[poly->npts-1].x; result->p[n2].x = poly->p[poly->npts-1].x;
result->p[n2].y = poly->p[0].y; result->p[n2].y = poly->p[0].y;
}; }
for (i=0; i<n2; i++) { for (i=0; i<n2; i++) {
result->p[i+n2+ii].x = poly->p[2*i+ii].y; /* even (+offset) indices */ result->p[i+n2+ii].x = poly->p[2*i+ii].y; /* even (+offset) indices */
result->p[i+n2+ii].y = poly->p[2*i+ii+1].y; /* odd (+offset) indices */ result->p[i+n2+ii].y = poly->p[2*i+ii+1].y; /* odd (+offset) indices */
}; }
return(result); return(result);
} /* revertpoly() */ } /* revertpoly() */
...@@ -3131,8 +3131,8 @@ CIRCLE *circle_in(char *str) ...@@ -3131,8 +3131,8 @@ CIRCLE *circle_in(char *str)
while (isspace( *cp)) cp++; while (isspace( *cp)) cp++;
if (*cp == LDELIM) { if (*cp == LDELIM) {
s = cp; s = cp;
}; }
}; }
if (! pair_decode( s, &circle->center.x, &circle->center.y, &s)) if (! pair_decode( s, &circle->center.x, &circle->center.y, &s))
elog (WARN, "Bad circle external representation '%s'",str); elog (WARN, "Bad circle external representation '%s'",str);
...@@ -3151,8 +3151,8 @@ CIRCLE *circle_in(char *str) ...@@ -3151,8 +3151,8 @@ CIRCLE *circle_in(char *str)
while (isspace( *s)) s++; while (isspace( *s)) s++;
} else { } else {
elog (WARN, "Bad circle external representation '%s'",str); elog (WARN, "Bad circle external representation '%s'",str);
}; }
}; }
if (*s != '\0') if (*s != '\0')
elog (WARN, "Bad circle external representation '%s'",str); elog (WARN, "Bad circle external representation '%s'",str);
...@@ -3628,7 +3628,7 @@ POLYGON *circle_poly(int npts, CIRCLE *circle) ...@@ -3628,7 +3628,7 @@ POLYGON *circle_poly(int npts, CIRCLE *circle)
angle = i*(2*PI/npts); angle = i*(2*PI/npts);
poly->p[i].x = circle->center.x - (circle->radius*cos(angle)); poly->p[i].x = circle->center.x - (circle->radius*cos(angle));
poly->p[i].y = circle->center.y + (circle->radius*sin(angle)); poly->p[i].y = circle->center.y + (circle->radius*sin(angle));
}; }
make_bound_box(poly); make_bound_box(poly);
...@@ -3660,13 +3660,13 @@ CIRCLE *poly_circle(POLYGON *poly) ...@@ -3660,13 +3660,13 @@ CIRCLE *poly_circle(POLYGON *poly)
for (i=0;i<poly->npts;i++) { for (i=0;i<poly->npts;i++) {
circle->center.x += poly->p[i].x; circle->center.x += poly->p[i].x;
circle->center.y += poly->p[i].y; circle->center.y += poly->p[i].y;
}; }
circle->center.x /= poly->npts; circle->center.x /= poly->npts;
circle->center.y /= poly->npts; circle->center.y /= poly->npts;
for (i=0;i<poly->npts;i++) { for (i=0;i<poly->npts;i++) {
circle->radius += point_dt( &poly->p[i], &circle->center); circle->radius += point_dt( &poly->p[i], &circle->center);
}; }
circle->radius /= poly->npts; circle->radius /= poly->npts;
if (FPzero(circle->radius)) if (FPzero(circle->radius))
...@@ -3762,8 +3762,8 @@ lseg_crossing( double x, double y, double px, double py) ...@@ -3762,8 +3762,8 @@ lseg_crossing( double x, double y, double px, double py)
} else { /* x < 0 */ } else { /* x < 0 */
if (FPzero( py)) return(FPlt( px, 0)? 0 : HIT_IT); if (FPzero( py)) return(FPlt( px, 0)? 0 : HIT_IT);
return(0); return(0);
}; }
}; }
/* Now we know y != 0; set sgn to sign of y */ /* Now we know y != 0; set sgn to sign of y */
sgn = (FPgt( y, 0)? 1 : -1); sgn = (FPgt( y, 0)? 1 : -1);
...@@ -3779,7 +3779,7 @@ lseg_crossing( double x, double y, double px, double py) ...@@ -3779,7 +3779,7 @@ lseg_crossing( double x, double y, double px, double py)
z = (x-px) * y - (y-py) * x; z = (x-px) * y - (y-py) * x;
if (FPzero( z)) return(HIT_IT); if (FPzero( z)) return(HIT_IT);
return( FPgt( (sgn*z), 0)? 0 : 2 * sgn); return( FPgt( (sgn*z), 0)? 0 : 2 * sgn);
}; }
} /* lseg_crossing() */ } /* lseg_crossing() */
...@@ -3802,8 +3802,8 @@ plist_same(int npts, Point p1[], Point p2[]) ...@@ -3802,8 +3802,8 @@ plist_same(int npts, Point p1[], Point p2[])
printf( "plist_same- %d failed forward match with %d\n", j, ii); printf( "plist_same- %d failed forward match with %d\n", j, ii);
#endif #endif
break; break;
}; }
}; }
#ifdef GEODEBUG #ifdef GEODEBUG
printf( "plist_same- ii = %d/%d after forward match\n", ii, npts); printf( "plist_same- ii = %d/%d after forward match\n", ii, npts);
#endif #endif
...@@ -3819,15 +3819,15 @@ printf( "plist_same- ii = %d/%d after forward match\n", ii, npts); ...@@ -3819,15 +3819,15 @@ printf( "plist_same- ii = %d/%d after forward match\n", ii, npts);
printf( "plist_same- %d failed reverse match with %d\n", j, ii); printf( "plist_same- %d failed reverse match with %d\n", j, ii);
#endif #endif
break; break;
}; }
}; }
#ifdef GEODEBUG #ifdef GEODEBUG
printf( "plist_same- ii = %d/%d after reverse match\n", ii, npts); printf( "plist_same- ii = %d/%d after reverse match\n", ii, npts);
#endif #endif
if (ii == npts) if (ii == npts)
return(TRUE); return(TRUE);
}; }
}; }
return(FALSE); return(FALSE);
} /* plist_same() */ } /* plist_same() */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment