From 745892fbddea56040139108277e728b53fd8fc11 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 28 May 2020 03:03:21 +0000 Subject: CTAN sync 202005280303 --- support/texlab/crates/bibutils_sys/src/pages.c | 87 -------------------------- 1 file changed, 87 deletions(-) delete mode 100644 support/texlab/crates/bibutils_sys/src/pages.c (limited to 'support/texlab/crates/bibutils_sys/src/pages.c') diff --git a/support/texlab/crates/bibutils_sys/src/pages.c b/support/texlab/crates/bibutils_sys/src/pages.c deleted file mode 100644 index b972b1f25f..0000000000 --- a/support/texlab/crates/bibutils_sys/src/pages.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * pages.c - * - * Copyright (c) Chris Putnam 2016-2019 - * - * Program and source code released under GPL verison 2 - */ -#include -#include -#include -#include "is_ws.h" -#include "utf8.h" -#include "pages.h" - -/* extract_range() - * - * Handle input strings like: - * - * "1-15" - * " 1 - 15 " - * " 1000--- 1500" - * " 1 <> 10" - * " 107 111" - */ -static void -extract_range( str *input, str *begin, str *end ) -{ - /* -30 is the first character of a UTF8 em-dash and en-dash */ - const char terminators[] = { ' ', '-', '\t', '\r', '\n', -30, '\0' }; - const char *p; - - str_empty( begin ); - str_empty( end ); - - if ( input->len==0 ) return; - - p = skip_ws( str_cstr( input ) ); - while ( *p && !strchr( terminators, *p ) ) - str_addchar( begin, *p++ ); - - p = skip_ws( p ); - - while ( *p=='-' ) p++; - while ( utf8_is_emdash( p ) ) p+=3; - while ( utf8_is_endash( p ) ) p+=3; - - p = skip_ws( p ); - - while ( *p && !strchr( terminators, *p ) ) - str_addchar( end, *p++ ); -} - -int -pages_add( fields *bibout, char *outtag, str *invalue, int level ) -{ - int fstatus, status = 1; - str start, stop; - - str_init( &start ); - str_init( &stop ); - - extract_range( invalue, &start, &stop ); - - if ( str_memerr( &start ) || str_memerr( &stop ) ) { - status = 0; - goto out; - } - - if ( start.len>0 ) { - fstatus = fields_add( bibout, "PAGES:START", str_cstr( &start ), level ); - if ( fstatus!=FIELDS_OK ) { - status = 0; - goto out; - } - } - - if ( stop.len>0 ) { - fstatus = fields_add( bibout, "PAGES:STOP", str_cstr( &stop ), level ); - if ( fstatus!=FIELDS_OK ) status = 0; - } - -out: - str_free( &start ); - str_free( &stop ); - return status; -} - -- cgit v1.2.3