Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libvc for openSUSE:Factory checked in at 2022-04-30 00:45:58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libvc (Old) and /work/SRC/openSUSE:Factory/.libvc.new.1538 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libvc" Sat Apr 30 00:45:58 2022 rev:6 rq:973884 version:011 Changes: -------- --- /work/SRC/openSUSE:Factory/libvc/libvc.changes 2021-02-07 15:23:50.806187370 +0100 +++ /work/SRC/openSUSE:Factory/.libvc.new.1538/libvc.changes 2022-04-30 00:46:28.571000224 +0200 @@ -1,0 +2,17 @@ +Mon Dec 13 16:04:08 UTC 2021 - Michael Vetter <[email protected]> + +- Update to 011: + * Improved parsing of large vCard files + +------------------------------------------------------------------- +Thu Dec 2 11:54:46 UTC 2021 - Michael Vetter <[email protected]> + +- Update to 010: + * Remove the calls to exit() in the shared library + * Extend API with called vc_get_error_message, that can be used + to retrieve the message of the last error encountered. + * The functions parse_vcard_file, vc_new, and vc_param_new return + NULL upon error. It is the responsibility of the calling code + to check the error message. + +------------------------------------------------------------------- Old: ---- v009.tar.gz New: ---- v011.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libvc.spec ++++++ --- /var/tmp/diff_new_pack.EaIjO2/_old 2022-04-30 00:46:29.075000661 +0200 +++ /var/tmp/diff_new_pack.EaIjO2/_new 2022-04-30 00:46:29.079000665 +0200 @@ -18,14 +18,14 @@ %define c_lib libvc0 Name: libvc -Version: 009 +Version: 011 Release: 0 Summary: Library to read and write vcard files License: LGPL-2.1-only Group: Development/Libraries/C and C++ URL: https://github.com/libvc/libvc Source0: https://github.com/libvc/libvc/archive/v%{version}.tar.gz -BuildRequires: autoconf +BuildRequires: autoconf >= 2.71 BuildRequires: automake BuildRequires: bison BuildRequires: byacc ++++++ v009.tar.gz -> v011.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libvc-009/AUTHORS new/libvc-011/AUTHORS --- old/libvc-009/AUTHORS 2021-02-05 10:02:43.000000000 +0100 +++ new/libvc-011/AUTHORS 2021-12-13 16:12:20.000000000 +0100 @@ -1,2 +1,3 @@ Andrew Hsu <[email protected]> Rafael Laboissi??re <[email protected]> +Matthew Hague <[email protected]> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libvc-009/Makefile.am new/libvc-011/Makefile.am --- old/libvc-009/Makefile.am 2021-02-05 10:02:43.000000000 +0100 +++ new/libvc-011/Makefile.am 2021-12-13 16:12:20.000000000 +0100 @@ -5,3 +5,4 @@ AUTOMAKE_OPTIONS = dist-bzip2 EXTRA_DIST = depcomp libvc.spec ACLOCAL_AMFLAGS = -I m4 +CLEANFILES = ylwrap diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libvc-009/NEWS new/libvc-011/NEWS --- old/libvc-009/NEWS 2021-02-05 10:02:43.000000000 +0100 +++ new/libvc-011/NEWS 2021-12-13 16:12:20.000000000 +0100 @@ -1,6 +1,7 @@ libvc 009 (2021-02-05) * Cope with libtoolize warnings regarding the m4 directory +* src/vc_parse.y: Drop non yacc-compatible %defines directive libvc 008 (2021-01-30) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libvc-009/TODO new/libvc-011/TODO --- old/libvc-009/TODO 2021-02-05 10:02:43.000000000 +0100 +++ new/libvc-011/TODO 2021-12-13 16:12:20.000000000 +0100 @@ -10,23 +10,3 @@ the vc_component as lowercase-only values. This will simplify the searching and comparison of these values and eliminate the need for strcasecmp in a lot of places. - -* Consider applying the patches in the patches/ directory, which were -taken from from https://github.com/yourealwaysbe/libvc: - -- https://github.com/yourealwaysbe/libvc/commit/5942b62db420781f3598ccc35b560bf66dc39965 - -This one improves the parsing times of large vcards and has a -significant impact. - -- https://github.com/yourealwaysbe/libvc/commit/d72dfdcf5722884a1fe79ea41343baa3673786a1 - -This one is necessary for fixing segfault caused by the previous patch. - -The problem with this patches is that the ABI is changed in (probably) -and non-backward compatible way. - -* When doing "make clean", remove the automatically generated files - src/vc_parse.c, src/vc_parse.h, and src/vc_scan.c. - -* Consider removing the calls to exit() in function vc_new(). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libvc-009/configure.ac new/libvc-011/configure.ac --- old/libvc-009/configure.ac 2021-02-05 10:02:43.000000000 +0100 +++ new/libvc-011/configure.ac 2021-12-13 16:12:20.000000000 +0100 @@ -2,13 +2,13 @@ # $Id: configure.ac,v 1.3 2003/06/14 01:54:15 ahsu Rel $ ### Versioning -AC_INIT([libvc],[009],[[email protected]]) -LIBVC_ABI_VERSION=0:1:0 +AC_INIT([libvc],[011],[[email protected]]) +LIBVC_ABI_VERSION=1:3:1 AC_SUBST(LIBVC_ABI_VERSION) ### Main definitions AM_INIT_AUTOMAKE -AC_PREREQ(2.59) +AC_PREREQ([2.71]) AC_COPYRIGHT([Copyright (C) 2003 Andrew Hsu Copyright (C) 2017, 2019-2021 Rafael Laboissi??re]) AC_REVISION($Revision: 1.3 $) @@ -17,14 +17,14 @@ ### Checks for programs. AC_PROG_CC -AC_PROG_LEX +AC_PROG_LEX([noyywrap]) AC_PROG_YACC -AC_PROG_LIBTOOL +LT_INIT AC_CHECK_PROG(have_shunit2,shunit2,yes) AM_CONDITIONAL([HAVE_SHUNIT2], [test x$have_shunit2 = xyes]) ### Checks for header files. -AC_HEADER_STDC +AC_CHECK_INCLUDES_DEFAULT ### Checks for typedefs, structures, and compiler characteristics. AC_C_CONST @@ -33,6 +33,10 @@ AC_FUNC_MALLOC AC_CHECK_FUNCS([strdup strcasecmp]) +### Checks for visibility suport +m4_include([m4/visibility.m4]) +gl_VISIBILITY + ### Output files AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile test/Makefile]) AC_OUTPUT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libvc-009/doc/vc.3 new/libvc-011/doc/vc.3 --- old/libvc-009/doc/vc.3 2021-02-05 10:02:43.000000000 +0100 +++ new/libvc-011/doc/vc.3 2021-12-13 16:12:20.000000000 +0100 @@ -14,6 +14,7 @@ .Nm vc_link , .Nm vc_append_with_name , .Nm vc_is_preferred , +.Nm vc_get_error_message , .Nm vc_get_preferred_tel , .Nm vc_get_preferred_email , .Nm vc_get_group , @@ -68,5 +69,6 @@ .Xr vc_delete 3 .Sh AUTHORS .An "Andrew Hsu" Aq [email protected] +.An "Rafael Laboissi??re" Aq [email protected] .Sh BUGS Parsing parameters is not finished yet. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libvc-009/m4/visibility.m4 new/libvc-011/m4/visibility.m4 --- old/libvc-009/m4/visibility.m4 1970-01-01 01:00:00.000000000 +0100 +++ new/libvc-011/m4/visibility.m4 2021-12-13 16:12:20.000000000 +0100 @@ -0,0 +1,82 @@ +# visibility.m4 serial 8 +dnl Copyright (C) 2005, 2008, 2010-2021 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl Tests whether the compiler supports the command-line option +dnl -fvisibility=hidden and the function and variable attributes +dnl __attribute__((__visibility__("hidden"))) and +dnl __attribute__((__visibility__("default"))). +dnl Does *not* test for __visibility__("protected") - which has tricky +dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on +dnl Mac OS X. +dnl Does *not* test for __visibility__("internal") - which has processor +dnl dependent semantics. +dnl Does *not* test for #pragma GCC visibility push(hidden) - which is +dnl "really only recommended for legacy code". +dnl Set the variable CFLAG_VISIBILITY. +dnl Defines and sets the variable HAVE_VISIBILITY. + +AC_DEFUN([gl_VISIBILITY], +[ + AC_REQUIRE([AC_PROG_CC]) + CFLAG_VISIBILITY= + HAVE_VISIBILITY=0 + if test -n "$GCC"; then + dnl First, check whether -Werror can be added to the command line, or + dnl whether it leads to an error because of some other option that the + dnl user has put into $CC $CFLAGS $CPPFLAGS. + AC_CACHE_CHECK([whether the -Werror option is usable], + [gl_cv_cc_vis_werror], + [gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [gl_cv_cc_vis_werror=yes], + [gl_cv_cc_vis_werror=no]) + CFLAGS="$gl_save_CFLAGS" + ]) + dnl Now check whether visibility declarations are supported. + AC_CACHE_CHECK([for simple visibility declarations], + [gl_cv_cc_visibility], + [gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fvisibility=hidden" + dnl We use the option -Werror and a function dummyfunc, because on some + dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning + dnl "visibility attribute not supported in this configuration; ignored" + dnl at the first function definition in every compilation unit, and we + dnl don't want to use the option in this case. + if test $gl_cv_cc_vis_werror = yes; then + CFLAGS="$CFLAGS -Werror" + fi + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[extern __attribute__((__visibility__("hidden"))) int hiddenvar; + extern __attribute__((__visibility__("default"))) int exportedvar; + extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); + extern __attribute__((__visibility__("default"))) int exportedfunc (void); + void dummyfunc (void); + int hiddenvar; + int exportedvar; + int hiddenfunc (void) { return 51; } + int exportedfunc (void) { return 1225736919; } + void dummyfunc (void) {} + ]], + [[]])], + [gl_cv_cc_visibility=yes], + [gl_cv_cc_visibility=no]) + CFLAGS="$gl_save_CFLAGS" + ]) + if test $gl_cv_cc_visibility = yes; then + CFLAG_VISIBILITY="-fvisibility=hidden" + HAVE_VISIBILITY=1 + fi + fi + AC_SUBST([CFLAG_VISIBILITY]) + AC_SUBST([HAVE_VISIBILITY]) + AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY], + [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.]) +]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libvc-009/patches/fix-segfault.patch new/libvc-011/patches/fix-segfault.patch --- old/libvc-009/patches/fix-segfault.patch 2021-02-05 10:02:43.000000000 +0100 +++ new/libvc-011/patches/fix-segfault.patch 1970-01-01 01:00:00.000000000 +0100 @@ -1,170 +0,0 @@ -commit d72dfdcf5722884a1fe79ea41343baa3673786a1 -Author: Matthew Hague <[email protected]> -Date: Tue Mar 29 01:32:21 2016 +0100 - - fixed segfault causes by using current_vcard when parse doesn't match anything, changed file location tracking mechanism so that reading extra large vcards doesn't cause the parsing to fail early - -diff --git a/src/vc_parse.y b/src/vc_parse.y -index b628b6b..e5d89cf 100644 ---- a/src/vc_parse.y -+++ b/src/vc_parse.y -@@ -98,7 +98,7 @@ group_contentline - - contentline - : name params ':' value '\n' -- | name ':' value '\n' -+ | name ':' value '\n' - ; - - name -@@ -160,15 +160,20 @@ vc_component * - parse_vcard_file (FILE * fp) - { - vc_component *vc = NULL; -+ current_vcard = NULL; - - yyin = fp; - -+ long pos = ftell(fp); -+ start_track_position(&pos); -+ - if (0 == yyparse ()) - { - vc = current_vcard; - } -- -- fseek(yyin, -chars_in_buffer(), SEEK_CUR); -+ -+ fseek(yyin, pos, SEEK_SET); -+ stop_track_position(); - flush_buffer(); - - return vc; -diff --git a/src/vc_scan.l b/src/vc_scan.l -index 6ea02dd..3fe6d71 100644 ---- a/src/vc_scan.l -+++ b/src/vc_scan.l -@@ -24,14 +24,23 @@ - #include "vc_parse.h" - - /** -- * Two functions to enable only buffering one card at a time -+ * Functions to enable only buffering one card at a time - */ - --int chars_in_buffer() -- { -- return YY_CURRENT_BUFFER->yy_n_chars - -- (yytext - YY_CURRENT_BUFFER->yy_ch_buf); -- } -+long *track_pos = NULL; -+ -+void start_track_position(long *pos) { -+ track_pos = pos; -+} -+ -+void stop_track_position() { -+ track_pos = NULL; -+} -+ -+static void move_pos(char *read) { -+ if (track_pos != NULL) -+ *track_pos += strlen(read); -+} - - void flush_buffer() - { -@@ -62,36 +71,75 @@ NAME-CHAR [\x21-\x2B\x2D\x2F-\x39\x3C\x3E-\x5A\x5C\x5E-\x7E] - - %% - --"BEGIN:VCARD" { yylval = NULL; return TOK_BEGIN_VCARD; } --"END:VCARD" { yylval = NULL; return TOK_END_VCARD; } --"\n" { yylval = NULL; return yytext[0]; } --"." { yylval = NULL; return yytext[0]; } --({ALPHA}|{DIGIT}|-)+/"." { yylval = yytext; return TOK_GROUP; } --{NAME-CHAR}+ { yylval = yytext; return TOK_NAME; } --";" { yylval = NULL; BEGIN(SC_PARAM); return yytext[0]; } --":" { yylval = NULL; BEGIN(SC_VALUE); return yytext[0]; } -+"BEGIN:VCARD" { move_pos("BEGIN:VCARD"); -+ yylval = NULL; -+ return TOK_BEGIN_VCARD; } -+"END:VCARD" { move_pos("END:VCARD"); -+ yylval = NULL; -+ return TOK_END_VCARD; } -+"\n" { move_pos("\n"); yylval = NULL; return yytext[0]; } -+"." { move_pos("."); yylval = NULL; return yytext[0]; } -+({ALPHA}|{DIGIT}|-)+/"." { move_pos(yytext); -+ yylval = yytext; -+ return TOK_GROUP; } -+{NAME-CHAR}+ { move_pos(yytext); -+ yylval = yytext; -+ return TOK_NAME; } -+";" { move_pos(";"); -+ yylval = NULL; -+ BEGIN(SC_PARAM); -+ return yytext[0]; } -+":" { move_pos(":"); -+ yylval = NULL; -+ BEGIN(SC_VALUE); -+ return yytext[0]; } - - <SC_VALUE> - { --({VALUE-CHAR}|"\n ")* { yylval = yytext; return TOK_VALUE; } --"\n" { yylval = NULL; BEGIN(INITIAL); return yytext[0]; } -+({VALUE-CHAR}|"\n ")* { move_pos(yytext); -+ yylval = yytext; -+ return TOK_VALUE; } -+"\n" { move_pos("\n"); -+ yylval = NULL; -+ BEGIN(INITIAL); -+ return yytext[0]; } - } - - <SC_PARAM> - { --({ALPHA}|{DIGIT}|-)+ { yylval = yytext; return TOK_PARAM_NAME; } --"=" { yylval = NULL; BEGIN(SC_PARAM_VALUE); -+({ALPHA}|{DIGIT}|-)+ { move_pos(yytext); -+ yylval = yytext; -+ return TOK_PARAM_NAME; } -+"=" { move_pos("="); -+ yylval = NULL; -+ BEGIN(SC_PARAM_VALUE); -+ return yytext[0]; } -+";" { move_pos(";"); -+ yylval = NULL; -+ BEGIN(SC_PARAM); -+ return yytext[0]; } -+":" { move_pos(":"); -+ yylval = NULL; -+ BEGIN(SC_VALUE); - return yytext[0]; } --";" { yylval = NULL; BEGIN(SC_PARAM); return yytext[0]; } --":" { yylval = NULL; BEGIN(SC_VALUE); return yytext[0]; } - } - - <SC_PARAM_VALUE> - { --{SAFE-CHAR}* { yylval = yytext; return TOK_PARAM_VALUE; } --"," { yylval = NULL; return yytext[0]; } --";" { yylval = NULL; BEGIN(SC_PARAM); return yytext[0]; } --":" { yylval = NULL; BEGIN(SC_VALUE); return yytext[0]; } -+{SAFE-CHAR}* { move_pos(yytext); -+ yylval = yytext; -+ return TOK_PARAM_VALUE; } -+"," { move_pos(","); -+ yylval = NULL; -+ return yytext[0]; } -+";" { move_pos(";"); -+ yylval = NULL; -+ BEGIN(SC_PARAM); -+ return yytext[0]; } -+":" { move_pos(":"); -+ yylval = NULL; -+ BEGIN(SC_VALUE); -+ return yytext[0]; } - } - - %% diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libvc-009/patches/improve-parsing-time-large-vcards.patch new/libvc-011/patches/improve-parsing-time-large-vcards.patch --- old/libvc-009/patches/improve-parsing-time-large-vcards.patch 2021-02-05 10:02:43.000000000 +0100 +++ new/libvc-011/patches/improve-parsing-time-large-vcards.patch 1970-01-01 01:00:00.000000000 +0100 @@ -1,63 +0,0 @@ -commit 5942b62db420781f3598ccc35b560bf66dc39965 -Author: Matthew Hague <[email protected]> -Date: Tue Sep 1 21:43:48 2015 +0100 - - improved parsing times of large vcards - -diff --git a/src/vc_parse.y b/src/vc_parse.y -index 61c36ad..b628b6b 100644 ---- a/src/vc_parse.y -+++ b/src/vc_parse.y -@@ -33,6 +33,9 @@ extern FILE *yyin; - extern int yylex (); - void yyerror (char *s); - -+extern long chars_in_buffer(); -+extern void flush_buffer(); -+ - vc_component *current_vcard = NULL; - vc_component *current_vc = NULL; - char *current_vc_param_name = NULL; -@@ -164,6 +167,9 @@ parse_vcard_file (FILE * fp) - { - vc = current_vcard; - } -+ -+ fseek(yyin, -chars_in_buffer(), SEEK_CUR); -+ flush_buffer(); - - return vc; - } -diff --git a/src/vc_scan.l b/src/vc_scan.l -index e726c44..6ea02dd 100644 ---- a/src/vc_scan.l -+++ b/src/vc_scan.l -@@ -23,14 +23,20 @@ - #define YYSTYPE char* - #include "vc_parse.h" - --/**************************************************** -- to force flex to scan only one character at a time -- ****************************************************/ --#define YY_INPUT(buf,result,max_size) \ -- { \ -- int c = getc(yyin); \ -- result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \ -- } -+/** -+ * Two functions to enable only buffering one card at a time -+ */ -+ -+int chars_in_buffer() -+ { -+ return YY_CURRENT_BUFFER->yy_n_chars - -+ (yytext - YY_CURRENT_BUFFER->yy_ch_buf); -+ } -+ -+void flush_buffer() -+ { -+ YY_FLUSH_BUFFER; -+ } - - /* TODO: clean up the token definitions to match the rfc */ - %} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libvc-009/src/Makefile.am new/libvc-011/src/Makefile.am --- old/libvc-009/src/Makefile.am 2021-02-05 10:02:43.000000000 +0100 +++ new/libvc-011/src/Makefile.am 2021-12-13 16:12:20.000000000 +0100 @@ -7,4 +7,5 @@ include_HEADERS = vc.h lib_LTLIBRARIES = libvc.la libvc_la_SOURCES = vc.c vc_parse.y vc_scan.l -libvc_la_LDFLAGS=-version-info $(LIBVC_ABI_VERSION) +libvc_la_LDFLAGS = -version-info $(LIBVC_ABI_VERSION) +CLEANFILES = vc_parse.c vc_parse.h vc_scan.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libvc-009/src/vc.c new/libvc-011/src/vc.c --- old/libvc-009/src/vc.c 2021-02-05 10:02:43.000000000 +0100 +++ new/libvc-011/src/vc.c 2021-12-13 16:12:20.000000000 +0100 @@ -30,6 +30,9 @@ #define BUF_LEN 80 +/*** ERROR MESSAGE ***/ +static char* vc_last_error_message = NULL; + /*** STRUCTS ***/ struct vc_component_tag @@ -51,6 +54,30 @@ /*** FUNCTION DEFINITIONS ***/ /*************************************************************************** + Set/get the last error message + */ + +void +#if HAVE_VISIBILITY +__attribute__((__visibility__("hidden"))) +#endif +vc_set_error_message (char *err_msg) +{ + if (NULL != vc_last_error_message) + { + free (vc_last_error_message); + } + vc_last_error_message = (char *) malloc ((strlen (err_msg) + 1) * sizeof (char)); + strcpy (vc_last_error_message, err_msg); +} + +char * +vc_get_error_message () +{ + return vc_last_error_message; +} + +/*************************************************************************** Returns a new vc_component with everything set to NULL. The user of the new vc_component will be responsible for freeing it in the future with a call to vc_delete or vc_delete_deep. @@ -65,8 +92,8 @@ if (NULL == new_vc) { - fprintf (stderr, "unable to malloc a new vc_component\n"); - exit (1); + vc_set_error_message ("unable to malloc a new vc_component"); + return NULL; } else { @@ -416,8 +443,8 @@ if (NULL == new_vc_param) { - fprintf (stderr, "unable to malloc a new vc_component_param\n"); - exit (1); + vc_set_error_message ("unable to malloc a new vc_component_param"); + return NULL; } else { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libvc-009/src/vc_parse.y new/libvc-011/src/vc_parse.y --- old/libvc-009/src/vc_parse.y 2021-02-05 10:02:43.000000000 +0100 +++ new/libvc-011/src/vc_parse.y 2021-12-13 16:12:20.000000000 +0100 @@ -25,6 +25,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <setjmp.h> #define YYSTYPE char* @@ -33,16 +34,20 @@ extern int yylex (); void yyerror (char *s); +extern long chars_in_buffer(); +extern void flush_buffer(); + vc_component *current_vcard = NULL; vc_component *current_vc = NULL; char *current_vc_param_name = NULL; -%} +jmp_buf +#if HAVE_VISIBILITY +__attribute__((__visibility__("hidden"))) +#endif +scan_recovery; -/*----------------------- - create a y.tab.h file - -----------------------*/ -%defines +%} %start vcard @@ -157,13 +162,24 @@ parse_vcard_file (FILE * fp) { vc_component *vc = NULL; + current_vcard = NULL; yyin = fp; - if (0 == yyparse ()) - { - vc = current_vcard; - } + long pos = ftell(fp); + start_track_position(&pos); + + if (!setjmp (scan_recovery)) + { + if (0 == yyparse ()) + { + vc = current_vcard; + } + } + + fseek(yyin, pos, SEEK_SET); + stop_track_position(); + flush_buffer(); return vc; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libvc-009/src/vc_scan.l new/libvc-011/src/vc_scan.l --- old/libvc-009/src/vc_scan.l 2021-02-05 10:02:43.000000000 +0100 +++ new/libvc-011/src/vc_scan.l 2021-12-13 16:12:20.000000000 +0100 @@ -22,15 +22,59 @@ %{ #define YYSTYPE char* #include "vc_parse.h" +#include <setjmp.h> -/**************************************************** - to force flex to scan only one character at a time - ****************************************************/ -#define YY_INPUT(buf,result,max_size) \ - { \ - int c = getc(yyin); \ - result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \ - } +/** + * Functions to enable only buffering one card at a time + */ + +long +#if HAVE_VISIBILITY +__attribute__((__visibility__("hidden"))) +#endif +*track_pos = NULL; + +#if HAVE_VISIBILITY +__attribute__((__visibility__("hidden"))) +#endif +void start_track_position(long *pos) { + track_pos = pos; +} + +#if HAVE_VISIBILITY +__attribute__((__visibility__("hidden"))) +#endif +void stop_track_position() { + track_pos = NULL; +} + +static void move_pos(char *read) { + if (track_pos != NULL) + *track_pos += strlen(read); +} + +#if HAVE_VISIBILITY +__attribute__((__visibility__("hidden"))) +#endif +void flush_buffer() + { + YY_FLUSH_BUFFER; + } + +/**************************************** + Recovery from fatal error in flex scan + ****************************************/ +#define YY_FATAL_ERROR(msg) vc_flex_fatal_error (msg); + +extern jmp_buf scan_recovery; +extern void vc_set_error_message (char *); + +static void +vc_flex_fatal_error (char *msg) +{ + vc_set_error_message (msg); + longjmp (scan_recovery, 1); +} /* TODO: clean up the token definitions to match the rfc */ %} @@ -56,36 +100,75 @@ %% -"BEGIN:VCARD" { yylval = NULL; return TOK_BEGIN_VCARD; } -"END:VCARD" { yylval = NULL; return TOK_END_VCARD; } -{LF} { yylval = NULL; return yytext[0]; } -"." { yylval = NULL; return yytext[0]; } -({ALPHA}|{DIGIT}|-)+/"." { yylval = yytext; return TOK_GROUP; } -{NAME-CHAR}+ { yylval = yytext; return TOK_NAME; } -";" { yylval = NULL; BEGIN(SC_PARAM); return yytext[0]; } -":" { yylval = NULL; BEGIN(SC_VALUE); return yytext[0]; } +"BEGIN:VCARD" { move_pos("BEGIN:VCARD"); + yylval = NULL; + return TOK_BEGIN_VCARD; } +"END:VCARD" { move_pos("END:VCARD"); + yylval = NULL; + return TOK_END_VCARD; } +{LF} { move_pos("\n"); yylval = NULL; return yytext[0]; } +"." { move_pos("."); yylval = NULL; return yytext[0]; } +({ALPHA}|{DIGIT}|-)+/"." { move_pos(yytext); + yylval = yytext; + return TOK_GROUP; } +{NAME-CHAR}+ { move_pos(yytext); + yylval = yytext; + return TOK_NAME; } +";" { move_pos(";"); + yylval = NULL; + BEGIN(SC_PARAM); + return yytext[0]; } +":" { move_pos(":"); + yylval = NULL; + BEGIN(SC_VALUE); + return yytext[0]; } <SC_VALUE> { -({VALUE-CHAR}|({CRLF}|{LF}){SP})* { yylval = yytext; return TOK_VALUE; } -{LF} { yylval = NULL; BEGIN(INITIAL); return yytext[0]; } +({VALUE-CHAR}|({CRLF}|{LF}){SP})* { move_pos(yytext); + yylval = yytext; + return TOK_VALUE; } +{LF} { move_pos("\n"); + yylval = NULL; + BEGIN(INITIAL); + return yytext[0]; } } <SC_PARAM> { -({ALPHA}|{DIGIT}|-)+ { yylval = yytext; return TOK_PARAM_NAME; } -"=" { yylval = NULL; BEGIN(SC_PARAM_VALUE); +({ALPHA}|{DIGIT}|-)+ { move_pos(yytext); + yylval = yytext; + return TOK_PARAM_NAME; } +"=" { move_pos("="); + yylval = NULL; + BEGIN(SC_PARAM_VALUE); + return yytext[0]; } +";" { move_pos(";"); + yylval = NULL; + BEGIN(SC_PARAM); + return yytext[0]; } +":" { move_pos(":"); + yylval = NULL; + BEGIN(SC_VALUE); return yytext[0]; } -";" { yylval = NULL; BEGIN(SC_PARAM); return yytext[0]; } -":" { yylval = NULL; BEGIN(SC_VALUE); return yytext[0]; } } <SC_PARAM_VALUE> { -{SAFE-CHAR}* { yylval = yytext; return TOK_PARAM_VALUE; } -"," { yylval = NULL; return yytext[0]; } -";" { yylval = NULL; BEGIN(SC_PARAM); return yytext[0]; } -":" { yylval = NULL; BEGIN(SC_VALUE); return yytext[0]; } +{SAFE-CHAR}* { move_pos(yytext); + yylval = yytext; + return TOK_PARAM_VALUE; } +"," { move_pos(","); + yylval = NULL; + return yytext[0]; } +";" { move_pos(";"); + yylval = NULL; + BEGIN(SC_PARAM); + return yytext[0]; } +":" { move_pos(":"); + yylval = NULL; + BEGIN(SC_VALUE); + return yytext[0]; } } %%
