From 59ae17964ac812515b47606eef8f69edf0f15684 Mon Sep 17 00:00:00 2001 From: Vitaly Davydov Date: Mon, 20 May 2024 16:41:21 +0300 Subject: [PATCH 01/12] Re-generate parser source files --- src/sparse.c | 180 +++++++++++++++++++++++++-------------------------- src/sparse.h | 10 +-- src/sscan.c | 60 ++++++++--------- 3 files changed, 125 insertions(+), 125 deletions(-) diff --git a/src/sparse.c b/src/sparse.c index f2200860..9eb7d578 100644 --- a/src/sparse.c +++ b/src/sparse.c @@ -74,7 +74,7 @@ #define yychar sphere_yychar /* First part of user prologue. */ -#line 1 "sparse.y" +#line 1 "src/sparse.y" #include #include @@ -110,7 +110,7 @@ static double human2dec(double d, double m, double s) } -#line 114 "sparse.c" +#line 114 "src/sparse.c" # ifndef YY_NULLPTR # if defined __cplusplus @@ -134,8 +134,8 @@ static double human2dec(double d, double m, double s) /* Use api.header.include to #include this header instead of duplicating it here. */ -#ifndef YY_SPHERE_YY_SPARSE_H_INCLUDED -# define YY_SPHERE_YY_SPARSE_H_INCLUDED +#ifndef YY_SPHERE_YY_SRC_SPARSE_H_INCLUDED +# define YY_SPHERE_YY_SRC_SPARSE_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -187,13 +187,13 @@ extern int sphere_yydebug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { -#line 41 "sparse.y" +#line 41 "src/sparse.y" int i; double d; char c[3]; -#line 197 "sparse.c" +#line 197 "src/sparse.c" }; typedef union YYSTYPE YYSTYPE; @@ -206,7 +206,7 @@ extern YYSTYPE sphere_yylval; int sphere_yyparse (void); -#endif /* !YY_SPHERE_YY_SPARSE_H_INCLUDED */ +#endif /* !YY_SPHERE_YY_SRC_SPARSE_H_INCLUDED */ @@ -1349,265 +1349,265 @@ yyparse (void) switch (yyn) { case 4: -#line 70 "sparse.y" +#line 70 "src/sparse.y" { set_spheretype( STYPE_POINT ); } -#line 1355 "sparse.c" +#line 1355 "src/sparse.c" break; case 5: -#line 71 "sparse.y" +#line 71 "src/sparse.y" { set_spheretype( STYPE_CIRCLE ); } -#line 1361 "sparse.c" +#line 1361 "src/sparse.c" break; case 6: -#line 72 "sparse.y" +#line 72 "src/sparse.y" { set_spheretype( STYPE_LINE ); } -#line 1367 "sparse.c" +#line 1367 "src/sparse.c" break; case 7: -#line 73 "sparse.y" +#line 73 "src/sparse.y" { set_spheretype( STYPE_EULER ); } -#line 1373 "sparse.c" +#line 1373 "src/sparse.c" break; case 8: -#line 74 "sparse.y" +#line 74 "src/sparse.y" { set_spheretype( STYPE_PATH ); } -#line 1379 "sparse.c" +#line 1379 "src/sparse.c" break; case 9: -#line 75 "sparse.y" +#line 75 "src/sparse.y" { set_spheretype( STYPE_ELLIPSE ); } -#line 1385 "sparse.c" +#line 1385 "src/sparse.c" break; case 10: -#line 76 "sparse.y" +#line 76 "src/sparse.y" { set_spheretype( STYPE_BOX ); } -#line 1391 "sparse.c" +#line 1391 "src/sparse.c" break; case 11: -#line 81 "sparse.y" +#line 81 "src/sparse.y" { (yyval.d) = (yyvsp[0].d); } -#line 1397 "sparse.c" +#line 1397 "src/sparse.c" break; case 12: -#line 82 "sparse.y" +#line 82 "src/sparse.y" { (yyval.d) = (yyvsp[0].i); } -#line 1403 "sparse.c" +#line 1403 "src/sparse.c" break; case 13: -#line 87 "sparse.y" +#line 87 "src/sparse.y" { (yyval.i) = set_angle(0, (yyvsp[0].d) ); } -#line 1409 "sparse.c" +#line 1409 "src/sparse.c" break; case 14: -#line 88 "sparse.y" +#line 88 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-1].d), 0, 0) ); } -#line 1415 "sparse.c" +#line 1415 "src/sparse.c" break; case 15: -#line 89 "sparse.y" +#line 89 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-1].i), 0, 0) ); } -#line 1421 "sparse.c" +#line 1421 "src/sparse.c" break; case 16: -#line 90 "sparse.y" +#line 90 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-2].i), (yyvsp[0].d), 0) ); } -#line 1427 "sparse.c" +#line 1427 "src/sparse.c" break; case 17: -#line 91 "sparse.y" +#line 91 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-3].i), (yyvsp[-1].d), 0) ); } -#line 1433 "sparse.c" +#line 1433 "src/sparse.c" break; case 18: -#line 92 "sparse.y" +#line 92 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-3].i), (yyvsp[-1].i), 0) ); } -#line 1439 "sparse.c" +#line 1439 "src/sparse.c" break; case 19: -#line 93 "sparse.y" +#line 93 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].d)) ); } -#line 1445 "sparse.c" +#line 1445 "src/sparse.c" break; case 20: -#line 94 "sparse.y" +#line 94 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-5].i), (yyvsp[-3].i), (yyvsp[-1].d)) ); } -#line 1451 "sparse.c" +#line 1451 "src/sparse.c" break; case 21: -#line 99 "sparse.y" +#line 99 "src/sparse.y" { (yyval.i) = set_angle(0, (yyvsp[0].d)); } -#line 1457 "sparse.c" +#line 1457 "src/sparse.c" break; case 22: -#line 100 "sparse.y" +#line 100 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-1].d), 0, 0)); } -#line 1463 "sparse.c" +#line 1463 "src/sparse.c" break; case 23: -#line 101 "sparse.y" +#line 101 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-1].i), 0, 0)); } -#line 1469 "sparse.c" +#line 1469 "src/sparse.c" break; case 24: -#line 102 "sparse.y" +#line 102 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-2].i), (yyvsp[0].d), 0)); } -#line 1475 "sparse.c" +#line 1475 "src/sparse.c" break; case 25: -#line 103 "sparse.y" +#line 103 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-3].i), (yyvsp[-1].d), 0)); } -#line 1481 "sparse.c" +#line 1481 "src/sparse.c" break; case 26: -#line 104 "sparse.y" +#line 104 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-3].i), (yyvsp[-1].i), 0)); } -#line 1487 "sparse.c" +#line 1487 "src/sparse.c" break; case 27: -#line 105 "sparse.y" +#line 105 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].d))); } -#line 1493 "sparse.c" +#line 1493 "src/sparse.c" break; case 28: -#line 106 "sparse.y" +#line 106 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-5].i), (yyvsp[-3].i), (yyvsp[-1].d))); } -#line 1499 "sparse.c" +#line 1499 "src/sparse.c" break; case 29: -#line 107 "sparse.y" +#line 107 "src/sparse.y" { (yyval.i) = set_angle(1, 15 * human2dec((yyvsp[-2].i), (yyvsp[0].d), 0)); } -#line 1505 "sparse.c" +#line 1505 "src/sparse.c" break; case 30: -#line 108 "sparse.y" +#line 108 "src/sparse.y" { (yyval.i) = set_angle(1, 15 * human2dec((yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].d))); } -#line 1511 "sparse.c" +#line 1511 "src/sparse.c" break; case 31: -#line 109 "sparse.y" +#line 109 "src/sparse.y" { (yyval.i) = set_angle(1, 15 * human2dec((yyvsp[-5].i), (yyvsp[-3].i), (yyvsp[-1].d))); } -#line 1517 "sparse.c" +#line 1517 "src/sparse.c" break; case 32: -#line 114 "sparse.y" +#line 114 "src/sparse.y" { (yyval.i) = set_angle_sign((yyvsp[0].i), 1); } -#line 1523 "sparse.c" +#line 1523 "src/sparse.c" break; case 33: -#line 115 "sparse.y" +#line 115 "src/sparse.y" { (yyval.i) = set_angle_sign((yyvsp[0].i), (yyvsp[-1].i)); } -#line 1529 "sparse.c" +#line 1529 "src/sparse.c" break; case 34: -#line 120 "sparse.y" +#line 120 "src/sparse.y" { (yyval.i) = set_angle_sign((yyvsp[0].i), 1); } -#line 1535 "sparse.c" +#line 1535 "src/sparse.c" break; case 35: -#line 121 "sparse.y" +#line 121 "src/sparse.y" { (yyval.i) = set_angle_sign((yyvsp[0].i), (yyvsp[-1].i)); } -#line 1541 "sparse.c" +#line 1541 "src/sparse.c" break; case 36: -#line 128 "sparse.y" +#line 128 "src/sparse.y" { (yyval.i) = set_point((yyvsp[-3].i), (yyvsp[-1].i)); } -#line 1549 "sparse.c" +#line 1549 "src/sparse.c" break; case 37: -#line 136 "sparse.y" +#line 136 "src/sparse.y" { set_circle((yyvsp[-3].i), (yyvsp[-1].i)); } -#line 1557 "sparse.c" +#line 1557 "src/sparse.c" break; case 38: -#line 144 "sparse.y" +#line 144 "src/sparse.y" { set_euler((yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].i), "ZXZ"); } -#line 1565 "sparse.c" +#line 1565 "src/sparse.c" break; case 39: -#line 148 "sparse.y" +#line 148 "src/sparse.y" { set_euler((yyvsp[-6].i), (yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].c)); } -#line 1573 "sparse.c" +#line 1573 "src/sparse.c" break; case 40: -#line 156 "sparse.y" +#line 156 "src/sparse.y" { set_line ((yyvsp[0].i)); } -#line 1581 "sparse.c" +#line 1581 "src/sparse.c" break; case 43: -#line 168 "sparse.y" +#line 168 "src/sparse.y" { } -#line 1587 "sparse.c" +#line 1587 "src/sparse.c" break; case 44: -#line 174 "sparse.y" +#line 174 "src/sparse.y" { set_ellipse((yyvsp[-8].i), (yyvsp[-6].i), (yyvsp[-3].i), (yyvsp[-1].i)); } -#line 1595 "sparse.c" +#line 1595 "src/sparse.c" break; case 45: -#line 181 "sparse.y" +#line 181 "src/sparse.y" { } -#line 1601 "sparse.c" +#line 1601 "src/sparse.c" break; case 46: -#line 182 "sparse.y" +#line 182 "src/sparse.y" { } -#line 1607 "sparse.c" +#line 1607 "src/sparse.c" break; -#line 1611 "sparse.c" +#line 1611 "src/sparse.c" default: break; } diff --git a/src/sparse.h b/src/sparse.h index 032b5fdb..e6a10008 100644 --- a/src/sparse.h +++ b/src/sparse.h @@ -34,8 +34,8 @@ /* Undocumented macros, especially those whose name start with YY_, are private implementation details. Do not rely on them. */ -#ifndef YY_SPHERE_YY_SPARSE_H_INCLUDED -# define YY_SPHERE_YY_SPARSE_H_INCLUDED +#ifndef YY_SPHERE_YY_SRC_SPARSE_H_INCLUDED +# define YY_SPHERE_YY_SRC_SPARSE_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -87,13 +87,13 @@ extern int sphere_yydebug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { -#line 41 "sparse.y" +#line 41 "src/sparse.y" int i; double d; char c[3]; -#line 97 "sparse.h" +#line 97 "src/sparse.h" }; typedef union YYSTYPE YYSTYPE; @@ -106,4 +106,4 @@ extern YYSTYPE sphere_yylval; int sphere_yyparse (void); -#endif /* !YY_SPHERE_YY_SPARSE_H_INCLUDED */ +#endif /* !YY_SPHERE_YY_SRC_SPARSE_H_INCLUDED */ diff --git a/src/sscan.c b/src/sscan.c index 3d904c67..0df711e4 100644 --- a/src/sscan.c +++ b/src/sscan.c @@ -1,6 +1,6 @@ -#line 2 "sscan.c" +#line 2 "src/sscan.c" -#line 4 "sscan.c" +#line 4 "src/sscan.c" #define YY_INT_ALIGNED short int @@ -722,8 +722,8 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "sscan.l" -#line 2 "sscan.l" +#line 1 "src/sscan.l" +#line 2 "src/sscan.l" #include #include "string.h" #include "sparse.h" @@ -745,8 +745,8 @@ void sphere_flush_scanner_buffer(void) { YY_FLUSH_BUFFER; } -#line 749 "sscan.c" -#line 750 "sscan.c" +#line 749 "src/sscan.c" +#line 750 "src/sscan.c" #define INITIAL 0 @@ -961,9 +961,9 @@ YY_DECL } { -#line 35 "sscan.l" +#line 35 "src/sscan.l" -#line 967 "sscan.c" +#line 967 "src/sscan.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1018,106 +1018,106 @@ YY_DECL case 1: YY_RULE_SETUP -#line 36 "sscan.l" +#line 36 "src/sscan.l" sphere_yylval.i = (strcmp("-", yytext)) ? (1) : (-1); return SIGN; YY_BREAK case 2: YY_RULE_SETUP -#line 37 "sscan.l" +#line 37 "src/sscan.l" sphere_yylval.i = atoi(yytext); return INT; YY_BREAK case 3: YY_RULE_SETUP -#line 38 "sscan.l" +#line 38 "src/sscan.l" sphere_yylval.d = atof(yytext); return FLOAT; YY_BREAK case 4: YY_RULE_SETUP -#line 39 "sscan.l" +#line 39 "src/sscan.l" memcpy(&sphere_yylval.c[0], yytext, 3); return EULERAXIS; YY_BREAK case 5: YY_RULE_SETUP -#line 40 "sscan.l" +#line 40 "src/sscan.l" return HOUR; YY_BREAK case 6: YY_RULE_SETUP -#line 41 "sscan.l" +#line 41 "src/sscan.l" return DEG; YY_BREAK case 7: YY_RULE_SETUP -#line 42 "sscan.l" +#line 42 "src/sscan.l" return MIN; YY_BREAK case 8: YY_RULE_SETUP -#line 43 "sscan.l" +#line 43 "src/sscan.l" return MIN; YY_BREAK case 9: YY_RULE_SETUP -#line 44 "sscan.l" +#line 44 "src/sscan.l" return SEC; YY_BREAK case 10: YY_RULE_SETUP -#line 45 "sscan.l" +#line 45 "src/sscan.l" return SEC; YY_BREAK case 11: YY_RULE_SETUP -#line 46 "sscan.l" +#line 46 "src/sscan.l" return COMMA; YY_BREAK case 12: YY_RULE_SETUP -#line 47 "sscan.l" +#line 47 "src/sscan.l" return OPENCIRC; YY_BREAK case 13: YY_RULE_SETUP -#line 48 "sscan.l" +#line 48 "src/sscan.l" return CLOSECIRC; YY_BREAK case 14: YY_RULE_SETUP -#line 49 "sscan.l" +#line 49 "src/sscan.l" return OPENPOINT; YY_BREAK case 15: YY_RULE_SETUP -#line 50 "sscan.l" +#line 50 "src/sscan.l" return CLOSEPOINT; YY_BREAK case 16: YY_RULE_SETUP -#line 51 "sscan.l" +#line 51 "src/sscan.l" return OPENARR; YY_BREAK case 17: YY_RULE_SETUP -#line 52 "sscan.l" +#line 52 "src/sscan.l" return CLOSEARR; YY_BREAK case 18: /* rule 18 can match eol */ YY_RULE_SETUP -#line 53 "sscan.l" +#line 53 "src/sscan.l" /* discard spaces */ YY_BREAK case 19: YY_RULE_SETUP -#line 54 "sscan.l" +#line 54 "src/sscan.l" /* alert parser of the garbage */ YY_BREAK case 20: YY_RULE_SETUP -#line 55 "sscan.l" +#line 55 "src/sscan.l" ECHO; YY_BREAK -#line 1121 "sscan.c" +#line 1121 "src/sscan.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -2086,6 +2086,6 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 55 "sscan.l" +#line 55 "src/sscan.l" From ac1d4ffa6339a79b46dba873f7d1c9d90e101b17 Mon Sep 17 00:00:00 2001 From: Vitaly Davydov Date: Mon, 20 May 2024 16:50:32 +0300 Subject: [PATCH 02/12] Fix build under mingw64 Add TOK_ prefix to INT, FLOAT, SIGN token names to distinguist these names from macro directives under mingw64. --- src/sparse.c | 105 ++++++++++++++++++++++++++------------------------- src/sparse.h | 12 +++--- src/sparse.y | 48 +++++++++++------------ src/sscan.c | 6 +-- src/sscan.l | 6 +-- 5 files changed, 89 insertions(+), 88 deletions(-) diff --git a/src/sparse.c b/src/sparse.c index 9eb7d578..16a65d11 100644 --- a/src/sparse.c +++ b/src/sparse.c @@ -160,9 +160,9 @@ extern int sphere_yydebug; CLOSEPOINT = 266, OPENARR = 267, CLOSEARR = 268, - SIGN = 269, - INT = 270, - FLOAT = 271, + TOK_SIGN = 269, + TOK_INT = 270, + TOK_FLOAT = 271, EULERAXIS = 272 }; #endif @@ -178,9 +178,9 @@ extern int sphere_yydebug; #define CLOSEPOINT 266 #define OPENARR 267 #define CLOSEARR 268 -#define SIGN 269 -#define INT 270 -#define FLOAT 271 +#define TOK_SIGN 269 +#define TOK_INT 270 +#define TOK_FLOAT 271 #define EULERAXIS 272 /* Value type. */ @@ -515,10 +515,11 @@ static const char *const yytname[] = { "$end", "error", "$undefined", "HOUR", "DEG", "MIN", "SEC", "COMMA", "OPENCIRC", "CLOSECIRC", "OPENPOINT", "CLOSEPOINT", "OPENARR", - "CLOSEARR", "SIGN", "INT", "FLOAT", "EULERAXIS", "$accept", "commands", - "command", "number", "angle_lat_us", "angle_long_us", "angle_long", - "angle_lat", "spherepoint", "spherecircle", "eulertrans", "sphereline", - "spherepointlist", "spherepath", "sphereellipse", "spherebox", YY_NULLPTR + "CLOSEARR", "TOK_SIGN", "TOK_INT", "TOK_FLOAT", "EULERAXIS", "$accept", + "commands", "command", "number", "angle_lat_us", "angle_long_us", + "angle_long", "angle_lat", "spherepoint", "spherecircle", "eulertrans", + "sphereline", "spherepointlist", "spherepath", "sphereellipse", + "spherebox", YY_NULLPTR }; #endif @@ -1351,193 +1352,193 @@ yyparse (void) case 4: #line 70 "src/sparse.y" { set_spheretype( STYPE_POINT ); } -#line 1355 "src/sparse.c" +#line 1356 "src/sparse.c" break; case 5: #line 71 "src/sparse.y" { set_spheretype( STYPE_CIRCLE ); } -#line 1361 "src/sparse.c" +#line 1362 "src/sparse.c" break; case 6: #line 72 "src/sparse.y" { set_spheretype( STYPE_LINE ); } -#line 1367 "src/sparse.c" +#line 1368 "src/sparse.c" break; case 7: #line 73 "src/sparse.y" { set_spheretype( STYPE_EULER ); } -#line 1373 "src/sparse.c" +#line 1374 "src/sparse.c" break; case 8: #line 74 "src/sparse.y" { set_spheretype( STYPE_PATH ); } -#line 1379 "src/sparse.c" +#line 1380 "src/sparse.c" break; case 9: #line 75 "src/sparse.y" { set_spheretype( STYPE_ELLIPSE ); } -#line 1385 "src/sparse.c" +#line 1386 "src/sparse.c" break; case 10: #line 76 "src/sparse.y" { set_spheretype( STYPE_BOX ); } -#line 1391 "src/sparse.c" +#line 1392 "src/sparse.c" break; case 11: #line 81 "src/sparse.y" { (yyval.d) = (yyvsp[0].d); } -#line 1397 "src/sparse.c" +#line 1398 "src/sparse.c" break; case 12: #line 82 "src/sparse.y" { (yyval.d) = (yyvsp[0].i); } -#line 1403 "src/sparse.c" +#line 1404 "src/sparse.c" break; case 13: #line 87 "src/sparse.y" { (yyval.i) = set_angle(0, (yyvsp[0].d) ); } -#line 1409 "src/sparse.c" +#line 1410 "src/sparse.c" break; case 14: #line 88 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-1].d), 0, 0) ); } -#line 1415 "src/sparse.c" +#line 1416 "src/sparse.c" break; case 15: #line 89 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-1].i), 0, 0) ); } -#line 1421 "src/sparse.c" +#line 1422 "src/sparse.c" break; case 16: #line 90 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-2].i), (yyvsp[0].d), 0) ); } -#line 1427 "src/sparse.c" +#line 1428 "src/sparse.c" break; case 17: #line 91 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-3].i), (yyvsp[-1].d), 0) ); } -#line 1433 "src/sparse.c" +#line 1434 "src/sparse.c" break; case 18: #line 92 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-3].i), (yyvsp[-1].i), 0) ); } -#line 1439 "src/sparse.c" +#line 1440 "src/sparse.c" break; case 19: #line 93 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].d)) ); } -#line 1445 "src/sparse.c" +#line 1446 "src/sparse.c" break; case 20: #line 94 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-5].i), (yyvsp[-3].i), (yyvsp[-1].d)) ); } -#line 1451 "src/sparse.c" +#line 1452 "src/sparse.c" break; case 21: #line 99 "src/sparse.y" { (yyval.i) = set_angle(0, (yyvsp[0].d)); } -#line 1457 "src/sparse.c" +#line 1458 "src/sparse.c" break; case 22: #line 100 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-1].d), 0, 0)); } -#line 1463 "src/sparse.c" +#line 1464 "src/sparse.c" break; case 23: #line 101 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-1].i), 0, 0)); } -#line 1469 "src/sparse.c" +#line 1470 "src/sparse.c" break; case 24: #line 102 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-2].i), (yyvsp[0].d), 0)); } -#line 1475 "src/sparse.c" +#line 1476 "src/sparse.c" break; case 25: #line 103 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-3].i), (yyvsp[-1].d), 0)); } -#line 1481 "src/sparse.c" +#line 1482 "src/sparse.c" break; case 26: #line 104 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-3].i), (yyvsp[-1].i), 0)); } -#line 1487 "src/sparse.c" +#line 1488 "src/sparse.c" break; case 27: #line 105 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].d))); } -#line 1493 "src/sparse.c" +#line 1494 "src/sparse.c" break; case 28: #line 106 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-5].i), (yyvsp[-3].i), (yyvsp[-1].d))); } -#line 1499 "src/sparse.c" +#line 1500 "src/sparse.c" break; case 29: #line 107 "src/sparse.y" { (yyval.i) = set_angle(1, 15 * human2dec((yyvsp[-2].i), (yyvsp[0].d), 0)); } -#line 1505 "src/sparse.c" +#line 1506 "src/sparse.c" break; case 30: #line 108 "src/sparse.y" { (yyval.i) = set_angle(1, 15 * human2dec((yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].d))); } -#line 1511 "src/sparse.c" +#line 1512 "src/sparse.c" break; case 31: #line 109 "src/sparse.y" { (yyval.i) = set_angle(1, 15 * human2dec((yyvsp[-5].i), (yyvsp[-3].i), (yyvsp[-1].d))); } -#line 1517 "src/sparse.c" +#line 1518 "src/sparse.c" break; case 32: #line 114 "src/sparse.y" { (yyval.i) = set_angle_sign((yyvsp[0].i), 1); } -#line 1523 "src/sparse.c" +#line 1524 "src/sparse.c" break; case 33: #line 115 "src/sparse.y" { (yyval.i) = set_angle_sign((yyvsp[0].i), (yyvsp[-1].i)); } -#line 1529 "src/sparse.c" +#line 1530 "src/sparse.c" break; case 34: #line 120 "src/sparse.y" { (yyval.i) = set_angle_sign((yyvsp[0].i), 1); } -#line 1535 "src/sparse.c" +#line 1536 "src/sparse.c" break; case 35: #line 121 "src/sparse.y" { (yyval.i) = set_angle_sign((yyvsp[0].i), (yyvsp[-1].i)); } -#line 1541 "src/sparse.c" +#line 1542 "src/sparse.c" break; case 36: @@ -1545,7 +1546,7 @@ yyparse (void) { (yyval.i) = set_point((yyvsp[-3].i), (yyvsp[-1].i)); } -#line 1549 "src/sparse.c" +#line 1550 "src/sparse.c" break; case 37: @@ -1553,7 +1554,7 @@ yyparse (void) { set_circle((yyvsp[-3].i), (yyvsp[-1].i)); } -#line 1557 "src/sparse.c" +#line 1558 "src/sparse.c" break; case 38: @@ -1561,7 +1562,7 @@ yyparse (void) { set_euler((yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].i), "ZXZ"); } -#line 1565 "src/sparse.c" +#line 1566 "src/sparse.c" break; case 39: @@ -1569,7 +1570,7 @@ yyparse (void) { set_euler((yyvsp[-6].i), (yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].c)); } -#line 1573 "src/sparse.c" +#line 1574 "src/sparse.c" break; case 40: @@ -1577,13 +1578,13 @@ yyparse (void) { set_line ((yyvsp[0].i)); } -#line 1581 "src/sparse.c" +#line 1582 "src/sparse.c" break; case 43: #line 168 "src/sparse.y" { } -#line 1587 "src/sparse.c" +#line 1588 "src/sparse.c" break; case 44: @@ -1591,23 +1592,23 @@ yyparse (void) { set_ellipse((yyvsp[-8].i), (yyvsp[-6].i), (yyvsp[-3].i), (yyvsp[-1].i)); } -#line 1595 "src/sparse.c" +#line 1596 "src/sparse.c" break; case 45: #line 181 "src/sparse.y" { } -#line 1601 "src/sparse.c" +#line 1602 "src/sparse.c" break; case 46: #line 182 "src/sparse.y" { } -#line 1607 "src/sparse.c" +#line 1608 "src/sparse.c" break; -#line 1611 "src/sparse.c" +#line 1612 "src/sparse.c" default: break; } diff --git a/src/sparse.h b/src/sparse.h index e6a10008..c6607ba4 100644 --- a/src/sparse.h +++ b/src/sparse.h @@ -60,9 +60,9 @@ extern int sphere_yydebug; CLOSEPOINT = 266, OPENARR = 267, CLOSEARR = 268, - SIGN = 269, - INT = 270, - FLOAT = 271, + TOK_SIGN = 269, + TOK_INT = 270, + TOK_FLOAT = 271, EULERAXIS = 272 }; #endif @@ -78,9 +78,9 @@ extern int sphere_yydebug; #define CLOSEPOINT 266 #define OPENARR 267 #define CLOSEARR 268 -#define SIGN 269 -#define INT 270 -#define FLOAT 271 +#define TOK_SIGN 269 +#define TOK_INT 270 +#define TOK_FLOAT 271 #define EULERAXIS 272 /* Value type. */ diff --git a/src/sparse.y b/src/sparse.y index 22e87781..0b65d9ff 100644 --- a/src/sparse.y +++ b/src/sparse.y @@ -44,9 +44,9 @@ static double human2dec(double d, double m, double s) char c[3]; } -%token SIGN -%token INT -%token FLOAT +%token TOK_SIGN +%token TOK_INT +%token TOK_FLOAT %token EULERAXIS %left COMMA @@ -78,47 +78,47 @@ command: /* unsigned number */ number : - FLOAT { $$ = $1; } - | INT { $$ = $1; } + TOK_FLOAT { $$ = $1; } + | TOK_INT { $$ = $1; } ; /* unsigned longitude */ angle_lat_us : number { $$ = set_angle(0, $1 ); } - | FLOAT DEG { $$ = set_angle(1, human2dec($1, 0, 0) ); } - | INT DEG { $$ = set_angle(1, human2dec($1, 0, 0) ); } - | INT DEG number { $$ = set_angle(1, human2dec($1, $3, 0) ); } - | INT DEG FLOAT MIN { $$ = set_angle(1, human2dec($1, $3, 0) ); } - | INT DEG INT MIN { $$ = set_angle(1, human2dec($1, $3, 0) ); } - | INT DEG INT MIN number { $$ = set_angle(1, human2dec($1, $3, $5) ); } - | INT DEG INT MIN number SEC { $$ = set_angle(1, human2dec($1, $3, $5) ); } + | TOK_FLOAT DEG { $$ = set_angle(1, human2dec($1, 0, 0) ); } + | TOK_INT DEG { $$ = set_angle(1, human2dec($1, 0, 0) ); } + | TOK_INT DEG number { $$ = set_angle(1, human2dec($1, $3, 0) ); } + | TOK_INT DEG TOK_FLOAT MIN { $$ = set_angle(1, human2dec($1, $3, 0) ); } + | TOK_INT DEG TOK_INT MIN { $$ = set_angle(1, human2dec($1, $3, 0) ); } + | TOK_INT DEG TOK_INT MIN number { $$ = set_angle(1, human2dec($1, $3, $5) ); } + | TOK_INT DEG TOK_INT MIN number SEC { $$ = set_angle(1, human2dec($1, $3, $5) ); } ; /* unsigned latitude */ angle_long_us : number { $$ = set_angle(0, $1); } - | FLOAT DEG { $$ = set_angle(1, human2dec($1, 0, 0)); } - | INT DEG { $$ = set_angle(1, human2dec($1, 0, 0)); } - | INT DEG number { $$ = set_angle(1, human2dec($1, $3, 0)); } - | INT DEG FLOAT MIN { $$ = set_angle(1, human2dec($1, $3, 0)); } - | INT DEG INT MIN { $$ = set_angle(1, human2dec($1, $3, 0)); } - | INT DEG INT MIN number { $$ = set_angle(1, human2dec($1, $3, $5)); } - | INT DEG INT MIN number SEC { $$ = set_angle(1, human2dec($1, $3, $5)); } - | INT HOUR number { $$ = set_angle(1, 15 * human2dec($1, $3, 0)); } - | INT HOUR INT MIN number { $$ = set_angle(1, 15 * human2dec($1, $3, $5)); } - | INT HOUR INT MIN number SEC { $$ = set_angle(1, 15 * human2dec($1, $3, $5)); } + | TOK_FLOAT DEG { $$ = set_angle(1, human2dec($1, 0, 0)); } + | TOK_INT DEG { $$ = set_angle(1, human2dec($1, 0, 0)); } + | TOK_INT DEG number { $$ = set_angle(1, human2dec($1, $3, 0)); } + | TOK_INT DEG TOK_FLOAT MIN { $$ = set_angle(1, human2dec($1, $3, 0)); } + | TOK_INT DEG TOK_INT MIN { $$ = set_angle(1, human2dec($1, $3, 0)); } + | TOK_INT DEG TOK_INT MIN number { $$ = set_angle(1, human2dec($1, $3, $5)); } + | TOK_INT DEG TOK_INT MIN number SEC { $$ = set_angle(1, human2dec($1, $3, $5)); } + | TOK_INT HOUR number { $$ = set_angle(1, 15 * human2dec($1, $3, 0)); } + | TOK_INT HOUR TOK_INT MIN number { $$ = set_angle(1, 15 * human2dec($1, $3, $5)); } + | TOK_INT HOUR TOK_INT MIN number SEC { $$ = set_angle(1, 15 * human2dec($1, $3, $5)); } ; /* longitude */ angle_long : angle_long_us { $$ = set_angle_sign($1, 1); } - | SIGN angle_long_us { $$ = set_angle_sign($2, $1); } + | TOK_SIGN angle_long_us { $$ = set_angle_sign($2, $1); } ; /* latitude */ angle_lat : angle_lat_us { $$ = set_angle_sign($1, 1); } - | SIGN angle_lat_us { $$ = set_angle_sign($2, $1); } + | TOK_SIGN angle_lat_us { $$ = set_angle_sign($2, $1); } ; diff --git a/src/sscan.c b/src/sscan.c index 0df711e4..50e0e70d 100644 --- a/src/sscan.c +++ b/src/sscan.c @@ -1019,17 +1019,17 @@ YY_DECL case 1: YY_RULE_SETUP #line 36 "src/sscan.l" -sphere_yylval.i = (strcmp("-", yytext)) ? (1) : (-1); return SIGN; +sphere_yylval.i = (strcmp("-", yytext)) ? (1) : (-1); return TOK_SIGN; YY_BREAK case 2: YY_RULE_SETUP #line 37 "src/sscan.l" -sphere_yylval.i = atoi(yytext); return INT; +sphere_yylval.i = atoi(yytext); return TOK_INT; YY_BREAK case 3: YY_RULE_SETUP #line 38 "src/sscan.l" -sphere_yylval.d = atof(yytext); return FLOAT; +sphere_yylval.d = atof(yytext); return TOK_FLOAT; YY_BREAK case 4: YY_RULE_SETUP diff --git a/src/sscan.l b/src/sscan.l index 99bd8ac6..d3103b6d 100644 --- a/src/sscan.l +++ b/src/sscan.l @@ -33,9 +33,9 @@ real ({int})?\.({int}) float ({int}|{real})([eE]{sign}{int})? %% -{sign} sphere_yylval.i = (strcmp("-", yytext)) ? (1) : (-1); return SIGN; -{int} sphere_yylval.i = atoi(yytext); return INT; -{float} sphere_yylval.d = atof(yytext); return FLOAT; +{sign} sphere_yylval.i = (strcmp("-", yytext)) ? (1) : (-1); return TOK_SIGN; +{int} sphere_yylval.i = atoi(yytext); return TOK_INT; +{float} sphere_yylval.d = atof(yytext); return TOK_FLOAT; [x-zX-Z]{3} memcpy(&sphere_yylval.c[0], yytext, 3); return EULERAXIS; h return HOUR; d return DEG; From 06074880bfff8024e269abf297794ccb04f82a84 Mon Sep 17 00:00:00 2001 From: Vitaly Davydov Date: Sat, 25 May 2024 17:29:15 +0300 Subject: [PATCH 03/12] Bump version up to 1.5.2 --- Makefile | 3 +++ Makefile.common.mk | 2 +- expected/version.out | 2 +- pg_sphere.control | 2 +- upgrade_scripts/pg_sphere--1.5.1--1.5.2.sql.in | 2 ++ 5 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 upgrade_scripts/pg_sphere--1.5.1--1.5.2.sql.in diff --git a/Makefile b/Makefile index 78f2dc5c..782961cd 100644 --- a/Makefile +++ b/Makefile @@ -218,6 +218,9 @@ pg_sphere--1.4.2--1.5.0.sql: pg_sphere--1.5.0--1.5.1.sql: cat upgrade_scripts/$@.in $^ > $@ +pg_sphere--1.5.1--1.5.2.sql: + cat upgrade_scripts/$@.in $^ > $@ + # end of local stuff src/sscan.o : src/sparse.c diff --git a/Makefile.common.mk b/Makefile.common.mk index be82047c..89632277 100644 --- a/Makefile.common.mk +++ b/Makefile.common.mk @@ -5,4 +5,4 @@ #---------------------------------------------------------------------------- EXTENSION := pg_sphere -PGSPHERE_VERSION := 1.5.1 +PGSPHERE_VERSION := 1.5.2 diff --git a/expected/version.out b/expected/version.out index ffad8f51..c1f0efe9 100644 --- a/expected/version.out +++ b/expected/version.out @@ -2,6 +2,6 @@ SELECT pg_sphere_version(); pg_sphere_version ------------------- - 1.5.1 + 1.5.2 (1 row) diff --git a/pg_sphere.control b/pg_sphere.control index 1e73251e..85f75896 100644 --- a/pg_sphere.control +++ b/pg_sphere.control @@ -1,5 +1,5 @@ # pg_sphere extension comment = 'spherical objects with useful functions, operators and index support' -default_version = '1.5.1' +default_version = '1.5.2' module_pathname = '$libdir/pg_sphere' relocatable = true diff --git a/upgrade_scripts/pg_sphere--1.5.1--1.5.2.sql.in b/upgrade_scripts/pg_sphere--1.5.1--1.5.2.sql.in new file mode 100644 index 00000000..3ff6a66e --- /dev/null +++ b/upgrade_scripts/pg_sphere--1.5.1--1.5.2.sql.in @@ -0,0 +1,2 @@ +-- Upgrade: 1.5.1 -> 1.5.2 +-- Nothing to do yet From e1dee2488847482d9cee29b6ff07a5e127c1cedb Mon Sep 17 00:00:00 2001 From: Markus Demleitner Date: Wed, 15 May 2024 15:35:20 +0200 Subject: [PATCH 04/12] Now more carefully nulling out null inputs in epoch_prop. This is so we do not invent values for pm, parallax, or rv. We are actually a bit over-cautious and invalidate both PMs even if only one is missing. This is because PMs mix, and hence there are traces of the invented 0 in the other component of the PM. Similarly, when the parallax is missing or bad, the RV would be heavily contaminated; in these cases, we copy through the original RV, as it may still be useful and certainly will not be grossly wrong. (sorry about a few whitespace diffs introduced by killing trailing whitespace in sql/epochprop.sql and src/epochprop.c) --- doc/functions.sgm | 9 ++++-- expected/epochprop.out | 62 +++++++++++++++++++++--------------------- sql/epochprop.sql | 26 +++++++++--------- src/epochprop.c | 37 +++++++++++++++---------- src/epochprop.h | 11 +------- 5 files changed, 73 insertions(+), 72 deletions(-) diff --git a/doc/functions.sgm b/doc/functions.sgm index 232b7552..047b7f11 100644 --- a/doc/functions.sgm +++ b/doc/functions.sgm @@ -867,9 +867,12 @@ It is an error to have either pos or delta_t NULL. For all other arguments, NULLs are turned into 0s, except for parallax, - where some very small default is put in. In that case, - both parallax and radial_velocity will be NULL in the output - array. + where some very small default is put in. Whatever is NULL + on the input is NULL on the output. In addition, we null + out a non-NULL input on one component of the proper motion + if the other component is NULL, and we null out the radial + velocity if the parallax is missing, as it would be horribly + off with the propagation algorithm we use here. diff --git a/expected/epochprop.out b/expected/epochprop.out index 3a528326..1111f1a7 100644 --- a/expected/epochprop.out +++ b/expected/epochprop.out @@ -1,5 +1,5 @@ -SET extra_float_digits = 2; -SELECT +SET extra_float_digits = 1; +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -7,7 +7,7 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 546.9759, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, -100) AS tp) AS q; @@ -16,7 +16,7 @@ FROM ( 269.4742714391 | 4.4072939987 | 543.624 | -791.442 | 10235.412 | -110.450 (1 row) -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -24,16 +24,16 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 0, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, -100) AS tp) AS q; - to_char | to_char | to_char | to_char | to_char | to_char ------------------+-----------------+---------+----------+------------+--------- - 269.4744079540 | 4.4055337210 | | -801.210 | 10361.762 | + to_char | to_char | to_char | to_char | to_char | to_char +-----------------+-----------------+----------+----------+------------+---------- + 269.4744079540 | 4.4055337210 | .000 | -801.210 | 10361.762 | -110.000 (1 row) -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -41,16 +41,16 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), NULL, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, -100) AS tp) AS q; - to_char | to_char | to_char | to_char | to_char | to_char ------------------+-----------------+---------+----------+------------+--------- - 269.4744079540 | 4.4055337210 | | -801.210 | 10361.762 | + to_char | to_char | to_char | to_char | to_char | to_char +-----------------+-----------------+---------+----------+------------+---------- + 269.4744079540 | 4.4055337210 | | -801.210 | 10361.762 | -110.000 (1 row) -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -58,16 +58,16 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 23, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), NULL, 20) AS tp) AS q; - to_char | to_char | to_char | to_char | to_char | to_char ------------------+-----------------+----------+----------+------------+---------- - 269.4476085384 | 4.7509315989 | 23.000 | -801.617 | 10361.984 | 2.159 + to_char | to_char | to_char | to_char | to_char | to_char +-----------------+-----------------+----------+----------+------------+--------- + 269.4476085384 | 4.7509315989 | 23.000 | -801.617 | 10361.984 | (1 row) -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -75,13 +75,13 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 23, NULL, RADIANS(10362/3.6e6), -110, 120) AS tp) AS q; - to_char | to_char | to_char | to_char | to_char | to_char ------------------+-----------------+----------+----------+------------+---------- - 269.4520769500 | 5.0388680565 | 23.007 | -.000 | 10368.061 | -97.120 + to_char | to_char | to_char | to_char | to_char | to_char +-----------------+-----------------+----------+---------+---------+---------- + 269.4520769500 | 4.6933649660 | 23.007 | | | -110.000 (1 row) SELECT epoch_prop(NULL, @@ -89,20 +89,20 @@ SELECT epoch_prop(NULL, 0.01 , RADIANS(10362/3.6e6), -110, 120); ERROR: NULL position not supported in epoch propagation -SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), +SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), 23, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, 20) AS tp; - tp ---------------------------------------------- - (4.7027479265831289 , 0.082919450934599334) + tp +------------------------------------------- + (4.702747926583129 , 0.08291945093459933) (1 row) -SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), +SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), 20) AS tp; - tp ---------------------------------------------- - (4.7027479306195161 , 0.082919398938087627) + tp +------------------------------------------- + (4.702747930619516 , 0.08291939893808763) (1 row) diff --git a/sql/epochprop.sql b/sql/epochprop.sql index d8ae2b7d..a6c69dd5 100644 --- a/sql/epochprop.sql +++ b/sql/epochprop.sql @@ -1,6 +1,6 @@ -SET extra_float_digits = 2; +SET extra_float_digits = 1; -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -8,12 +8,12 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 546.9759, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, -100) AS tp) AS q; -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -21,12 +21,12 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 0, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, -100) AS tp) AS q; -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -34,12 +34,12 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), NULL, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, -100) AS tp) AS q; -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -47,12 +47,12 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 23, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), NULL, 20) AS tp) AS q; -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -60,7 +60,7 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 23, NULL, RADIANS(10362/3.6e6), -110, 120) AS tp) AS q; @@ -70,11 +70,11 @@ SELECT epoch_prop(NULL, 0.01 , RADIANS(10362/3.6e6), -110, 120); -SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), +SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), 23, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, 20) AS tp; -SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), +SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), 20) AS tp; diff --git a/src/epochprop.c b/src/epochprop.c index ab9abc88..12ad6219 100644 --- a/src/epochprop.c +++ b/src/epochprop.c @@ -133,6 +133,7 @@ epoch_prop(PG_FUNCTION_ARGS) { phasevec input, output; ArrayType *result; Datum retvals[6]; + bool output_null[6] = {0, 0, 0, 0, 0, 0}; if (PG_ARGISNULL(0)) { ereport(ERROR, @@ -141,25 +142,29 @@ epoch_prop(PG_FUNCTION_ARGS) { memcpy(&(input.pos), (void*)PG_GETARG_POINTER(0), sizeof(SPoint)); if (PG_ARGISNULL(1)) { input.parallax = 0; + output_null[2] = 1; + /* The way we do our computation, with a bad parallax the RV + will be horribly off, too, so null this out, too; if avaialble, + we will fiddle in the original RV below again. */ + output_null[5] = 1; } else { input.parallax = PG_GETARG_FLOAT8(1); } input.parallax_valid = fabs(input.parallax) > PX_MIN; - - if (PG_ARGISNULL(2)) { - input.pm[0] = 0; - } else { - input.pm[0] = PG_GETARG_FLOAT8(2); - } - if (PG_ARGISNULL(3)) { + if (PG_ARGISNULL(2) || PG_ARGISNULL(3)) { + input.pm[0] = 0; input.pm[1] = 0; + output_null[3] = 1; + output_null[4] = 1; } else { + input.pm[0] = PG_GETARG_FLOAT8(2); input.pm[1] = PG_GETARG_FLOAT8(3); } if (PG_ARGISNULL(4)) { input.rv = 0; + output_null[5] = 1; } else { input.rv = PG_GETARG_FLOAT8(4); } @@ -172,6 +177,15 @@ epoch_prop(PG_FUNCTION_ARGS) { propagate_phasevec(&input, delta_t, &output); + /* If we have an invalid parallax but a good RV, preserve the original, + untransformed RV on output. See + https://github.com/ivoa-std/udf-catalogue/pull/20#issuecomment-2115053757 + for the rationale. */ + if (!PG_ARGISNULL(4) && !input.parallax_valid) { + output_null[5] = 0; + output.rv = input.rv; + } + /* change to internal units: rad, rad/yr, mas, and km/s */ retvals[0] = Float8GetDatum(output.pos.lng); retvals[1] = Float8GetDatum(output.pos.lat); @@ -181,7 +195,6 @@ epoch_prop(PG_FUNCTION_ARGS) { retvals[5] = Float8GetDatum(output.rv); { - bool isnull[6] = {0, 0, 0, 0, 0, 0}; int lower_bounds[1] = {1}; int dims[1] = {6}; #ifdef USE_FLOAT8_BYVAL @@ -190,13 +203,7 @@ epoch_prop(PG_FUNCTION_ARGS) { bool embyval = false; #endif - if (! output.parallax_valid) { - /* invalidate parallax and rv */ - isnull[2] = 1; - isnull[5] = 1; - } - - result = construct_md_array(retvals, isnull, 1, dims, lower_bounds, + result = construct_md_array(retvals, output_null, 1, dims, lower_bounds, FLOAT8OID, sizeof(float8), embyval, 'd'); } PG_RETURN_ARRAYTYPE_P(result); diff --git a/src/epochprop.h b/src/epochprop.h index a93e4c34..3b61a02c 100644 --- a/src/epochprop.h +++ b/src/epochprop.h @@ -6,15 +6,6 @@ extern Datum epoch_prop(PG_FUNCTION_ARGS); -/* a cartesian point; this is like geo_decl's point, but you can't -have both geo_decls and pg_sphere right now (both define a type Point, -not to mention they have different ideas on EPSILON */ -typedef struct s_cpoint -{ - double x, - y; -} CPoint; - typedef struct s_phasevec { SPoint pos; /* Position as an SPoint */ @@ -22,5 +13,5 @@ typedef struct s_phasevec * longitude has cos(lat) applied */ double parallax; /* in rad */ double rv; /* radial velocity in km/s */ - int parallax_valid; /* 1 if the parallax really is a NULL */ + int parallax_valid; /* 1 if we accept the parallax as physical */ } phasevec; From adda8984d20fa13d7b017c59e76a3e5ac905264c Mon Sep 17 00:00:00 2001 From: Ed Sabol Date: Sun, 2 Jun 2024 15:52:30 -0400 Subject: [PATCH 05/12] Issue #125: Add PostgreSQL 17 builds to CI workflow This merge request addresses issue #125 by updating the GitHub Actions CI workflow to build and test on PostrgeSQL 17. --- .github/workflows/build-and-check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-check.yml b/.github/workflows/build-and-check.yml index a4247b8a..f7633b55 100644 --- a/.github/workflows/build-and-check.yml +++ b/.github/workflows/build-and-check.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - pg_version: [10, 11, 12, 13, 14, 15, 16] + pg_version: [10, 11, 12, 13, 14, 15, 16, 17] use_healpix: [0, 1] name: PostgreSQL ${{ matrix.pg_version }} - USE_HEALPIX=${{ matrix.use_healpix }} @@ -29,7 +29,7 @@ jobs: xsltproc \ fop - - name: Install Postgres + - name: Install PostgreSQL run: sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -p -v ${{ matrix.pg_version }} -i - name: Clone pgSphere From bd5915ad7a06f2494dedc6f6fc44999a5002e100 Mon Sep 17 00:00:00 2001 From: Vitaly Davydov Date: Mon, 14 Oct 2024 16:00:57 +0300 Subject: [PATCH 06/12] Enable manual run of the build workflow --- .github/workflows/build-and-check.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-and-check.yml b/.github/workflows/build-and-check.yml index f7633b55..6038637e 100644 --- a/.github/workflows/build-and-check.yml +++ b/.github/workflows/build-and-check.yml @@ -3,6 +3,9 @@ name: Build and Check on: push: pull_request: + workflow_dispatch: + schedule: + - cron: '0 0 * * 5' jobs: build_and_test: From dcdc52ff2866c2abe13951b9f257c118d2d4bcb8 Mon Sep 17 00:00:00 2001 From: Ed Sabol Date: Tue, 15 Oct 2024 15:51:30 -0400 Subject: [PATCH 07/12] Update actions/upload-artifact version in CI workflow This PR updates the version number on `actions/upload-artifact` in `.github/workflows/build-and-check.yml` in order to silence the following warning: > The following actions use a deprecated Node.js version and will be forced to run on node20: actions/upload-artifact@v3. For more info: https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/ https://github.com/actions/upload-artifact says: > actions/upload-artifact@v3 is scheduled for deprecation on November 30, 2024. [Learn more.](https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/) Similarly, v1/v2 are scheduled for deprecation on June 30, 2024. Please update your workflow to use v4 of the artifact actions. This deprecation will not impact any existing versions of GitHub Enterprise Server being used by customers. --- .github/workflows/build-and-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-check.yml b/.github/workflows/build-and-check.yml index 6038637e..b89bdba0 100644 --- a/.github/workflows/build-and-check.yml +++ b/.github/workflows/build-and-check.yml @@ -75,7 +75,7 @@ jobs: uses: rlespinasse/github-slug-action@v4 - name: Upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: success() || failure() with: name: ${{ env.GITHUB_REF_SLUG_URL }}-pg${{ matrix.pg_version }}-use-healpix-${{ matrix.use_healpix }}-${{ github.run_id }} From e059e5e462eb902614e8aaa91ae88a9c1100600c Mon Sep 17 00:00:00 2001 From: Vitaly Davydov Date: Mon, 28 Oct 2024 09:30:30 +0300 Subject: [PATCH 08/12] Build and check workflow for MS Windows --- .../build-and-check-windows-latest.yml | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/build-and-check-windows-latest.yml diff --git a/.github/workflows/build-and-check-windows-latest.yml b/.github/workflows/build-and-check-windows-latest.yml new file mode 100644 index 00000000..4189fc22 --- /dev/null +++ b/.github/workflows/build-and-check-windows-latest.yml @@ -0,0 +1,81 @@ +name: Build and Check (windows-latest) + +on: + push: + pull_request: + workflow_dispatch: + schedule: + - cron: '0 0 * * 5' + +jobs: + build_and_test: + + runs-on: windows-latest + + strategy: + fail-fast: false + matrix: + pg_version: [10, 11, 12, 13, 14, 15, 16, 17] + use_healpix: [0] + + name: PostgreSQL ${{ matrix.pg_version }} - USE_HEALPIX=${{ matrix.use_healpix }} (windows-latest) + + defaults: + run: + shell: msys2 {0} + + steps: + + - name: Install MSYS2 + uses: msys2/setup-msys2@v2 + with: + update: true + msystem: mingw64 + install: >- + base-devel + curl + git + make + perl + flex + bison + diffutils + mingw-w64-x86_64-zlib + mingw-w64-x86_64-icu + mingw-w64-x86_64-gcc + + - name: Install PostgreSQL + run: | + echo "Workspace: ${GITHUB_WORKSPACE}" + git clone --single-branch -b "REL_${{ matrix.pg_version }}_STABLE" git://git.postgresql.org/git/postgresql.git + cd ${GITHUB_WORKSPACE}/postgresql + ./configure --enable-cassert --without-icu + make -j$(nproc) + make install + + - name: Clone pgSphere + uses: actions/checkout@v4 + with: + ref: 'master' + fetch-depth: 1 + + - name: Build pgSphere + run: | + make --keep-going -j$(nproc) PROFILE='-Werror -Wall' USE_HEALPIX=0 + make USE_HEALPIX=0 install + + - name: Test pgSphere + run: | + initdb -D pgdata -U postgres + pg_ctl -D pgdata -l postgres.log start + make USE_HEALPIX=0 installcheck + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + if: success() || failure() + with: + name: ${{ env.GITHUB_REF_SLUG_URL }}-pg${{ matrix.pg_version }}-use-healpix-${{ matrix.use_healpix }}-${{ github.run_id }} + if-no-files-found: ignore + path: | + ./**/*.log + ./**/*.diffs From 50268d5ac33893c41dcf5e95bfffc7eefc470d0d Mon Sep 17 00:00:00 2001 From: Vitaly Davydov Date: Tue, 5 Nov 2024 13:48:10 +0300 Subject: [PATCH 09/12] Fix found issues after review --- .github/workflows/build-and-check-windows-latest.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-and-check-windows-latest.yml b/.github/workflows/build-and-check-windows-latest.yml index 4189fc22..b4c81583 100644 --- a/.github/workflows/build-and-check-windows-latest.yml +++ b/.github/workflows/build-and-check-windows-latest.yml @@ -70,6 +70,10 @@ jobs: pg_ctl -D pgdata -l postgres.log start make USE_HEALPIX=0 installcheck + - name: Show installcheck regression.diffs + if: ${{ failure() }} + run: cat regression.diffs + - name: Upload artifacts uses: actions/upload-artifact@v4 if: success() || failure() From 37897e98169c0e1fdcb8101764f095c94aa081a6 Mon Sep 17 00:00:00 2001 From: Vitaly Davydov Date: Thu, 7 Nov 2024 12:47:14 +0300 Subject: [PATCH 10/12] Add crushtest in build-and-check-windows-latest workflow --- .../workflows/build-and-check-windows-latest.yml | 14 +++++++++++++- expected/init_extended.out | 6 +++--- sql/init_extended.sql | 6 +++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-check-windows-latest.yml b/.github/workflows/build-and-check-windows-latest.yml index b4c81583..1bbb43e9 100644 --- a/.github/workflows/build-and-check-windows-latest.yml +++ b/.github/workflows/build-and-check-windows-latest.yml @@ -64,16 +64,28 @@ jobs: make --keep-going -j$(nproc) PROFILE='-Werror -Wall' USE_HEALPIX=0 make USE_HEALPIX=0 install - - name: Test pgSphere + - name: Test pgSphere (installcheck) run: | initdb -D pgdata -U postgres pg_ctl -D pgdata -l postgres.log start make USE_HEALPIX=0 installcheck + pg_ctl -D pgdata -l postgres_installcheck.log stop + rm -rf pgdata - name: Show installcheck regression.diffs if: ${{ failure() }} run: cat regression.diffs + - name: Test pgSphere (crushtest) + run: | + initdb -D pgdata -U postgres + pg_ctl -D pgdata -l postgres_crushtest.log start + make USE_HEALPIX=0 crushtest + + - name: Show crushtest regression.diffs + if: ${{ failure() }} + run: cat regression.diffs + - name: Upload artifacts uses: actions/upload-artifact@v4 if: success() || failure() diff --git a/expected/init_extended.out b/expected/init_extended.out index 382a0dcb..adeaa8d8 100644 --- a/expected/init_extended.out +++ b/expected/init_extended.out @@ -1,18 +1,18 @@ -- indexed operations..... -- spoint_data and scircle_data tables have to be created and indexed using -\! testsuite/gen_point.pl 1 > results/gen_point_1.sql +\! perl testsuite/gen_point.pl 1 > results/gen_point_1.sql \i results/gen_point_1.sql CREATE TABLE spoint_data (sp spoint); COPY spoint_data (sp) FROM stdin; CREATE INDEX sp_idx ON spoint_data USING gist (sp); -- and -\! testsuite/gen_circle.pl 1 0.1 > results/gen_circle_1_0.1.sql +\! perl testsuite/gen_circle.pl 1 0.1 > results/gen_circle_1_0.1.sql \i results/gen_circle_1_0.1.sql CREATE TABLE scircle_data (sc scircle); COPY scircle_data (sc) FROM stdin; CREATE INDEX sc_idx ON scircle_data USING gist (sc); -- -\! testsuite/gen_poly.pl 1 0.1 4 > results/gen_poly_1_0.1_4.sql +\! perl testsuite/gen_poly.pl 1 0.1 4 > results/gen_poly_1_0.1_4.sql \i results/gen_poly_1_0.1_4.sql CREATE TABLE spoly_data (sp spoly); COPY spoly_data (sp) FROM stdin; diff --git a/sql/init_extended.sql b/sql/init_extended.sql index 800d7e46..b28f0efd 100644 --- a/sql/init_extended.sql +++ b/sql/init_extended.sql @@ -2,15 +2,15 @@ -- spoint_data and scircle_data tables have to be created and indexed using -\! testsuite/gen_point.pl 1 > results/gen_point_1.sql +\! perl testsuite/gen_point.pl 1 > results/gen_point_1.sql \i results/gen_point_1.sql -- and -\! testsuite/gen_circle.pl 1 0.1 > results/gen_circle_1_0.1.sql +\! perl testsuite/gen_circle.pl 1 0.1 > results/gen_circle_1_0.1.sql \i results/gen_circle_1_0.1.sql -- -\! testsuite/gen_poly.pl 1 0.1 4 > results/gen_poly_1_0.1_4.sql +\! perl testsuite/gen_poly.pl 1 0.1 4 > results/gen_poly_1_0.1_4.sql \i results/gen_poly_1_0.1_4.sql From 6c244248c9daa5cb1cf0bfb7e2de37ad70c90f46 Mon Sep 17 00:00:00 2001 From: Vitaly Davydov Date: Thu, 7 Nov 2024 13:13:18 +0300 Subject: [PATCH 11/12] Fix pgsphere cloned branch --- .github/workflows/build-and-check-windows-latest.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build-and-check-windows-latest.yml b/.github/workflows/build-and-check-windows-latest.yml index 1bbb43e9..658da283 100644 --- a/.github/workflows/build-and-check-windows-latest.yml +++ b/.github/workflows/build-and-check-windows-latest.yml @@ -55,9 +55,6 @@ jobs: - name: Clone pgSphere uses: actions/checkout@v4 - with: - ref: 'master' - fetch-depth: 1 - name: Build pgSphere run: | From 461e873748d68498db50893acd6397c5f0ec9239 Mon Sep 17 00:00:00 2001 From: Vitaly Davydov Date: Thu, 7 Nov 2024 14:57:11 +0300 Subject: [PATCH 12/12] Change log file name --- .github/workflows/build-and-check-windows-latest.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-check-windows-latest.yml b/.github/workflows/build-and-check-windows-latest.yml index 658da283..e2d7b274 100644 --- a/.github/workflows/build-and-check-windows-latest.yml +++ b/.github/workflows/build-and-check-windows-latest.yml @@ -64,9 +64,9 @@ jobs: - name: Test pgSphere (installcheck) run: | initdb -D pgdata -U postgres - pg_ctl -D pgdata -l postgres.log start + pg_ctl -D pgdata -l postgres_installcheck.log start make USE_HEALPIX=0 installcheck - pg_ctl -D pgdata -l postgres_installcheck.log stop + pg_ctl -D pgdata stop rm -rf pgdata - name: Show installcheck regression.diffs @@ -78,6 +78,7 @@ jobs: initdb -D pgdata -U postgres pg_ctl -D pgdata -l postgres_crushtest.log start make USE_HEALPIX=0 crushtest + pg_ctl -D pgdata stop - name: Show crushtest regression.diffs if: ${{ failure() }}