Commit 3f47016b authored by Koen Martens's avatar Koen Martens

Add empty lines to #else if replacing #elif to avoid deleting lines.

parent 2f0c9d4c
This diff is collapsed.
......@@ -4,7 +4,7 @@
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = sunifdef
PROJECT_NUMBER = 3.1.3
PROJECT_NUMBER = 4.0.0
OUTPUT_DIRECTORY = .
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
......
......@@ -2257,7 +2257,7 @@ fi
# Define the identity of the package.
PACKAGE=sunifdef
VERSION=3.1.3
VERSION=4.0.0
cat >>confdefs.h <<_ACEOF
......
AC_INIT(configure.in)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(sunifdef, 3.1.3)
AM_INIT_AUTOMAKE(sunifdef, 4.0.0)
AC_CHECK_HEADERS(stdbool.h)
AC_LANG_C
......
......@@ -11,9 +11,10 @@ sunifdef_SOURCES = args.c args.h bool.h categorical.c categorical.h chew.c \
exception.h file_tree.c file_tree.h filesys.c filesys.h fs_nix.c fs_win.c \
if_control.c if_control.h io.c io.h line_despatch.c line_despatch.h line_edit.c \
line_edit.h main.c memory.c memory.h opts.h platform.h ptr_vector.c ptr_vector.h \
report.c report.h state_utils.c state_utils.h symbol_table.c symbol_table.h
report.c report.h state_utils.c state_utils.h symbol_table.c symbol_table.h \
string_util.c string_util.h
noinst_HEADERS = args.h bool.h categorical.h chew.h doxygen.h evaluator.h \
if_control.h io.h line_despatch.h line_edit.h memory.h platform.h ptr_vector.h \
state_utils.h symbol_table.h opts.h file_tree.h filesys.h exception.h dataset.h \
report.h
report.h string_util.h
......@@ -53,7 +53,8 @@ am_sunifdef_OBJECTS = args.$(OBJEXT) categorical.$(OBJEXT) \
fs_nix.$(OBJEXT) fs_win.$(OBJEXT) if_control.$(OBJEXT) \
io.$(OBJEXT) line_despatch.$(OBJEXT) line_edit.$(OBJEXT) \
main.$(OBJEXT) memory.$(OBJEXT) ptr_vector.$(OBJEXT) \
report.$(OBJEXT) state_utils.$(OBJEXT) symbol_table.$(OBJEXT)
report.$(OBJEXT) state_utils.$(OBJEXT) symbol_table.$(OBJEXT) \
string_util.$(OBJEXT)
sunifdef_OBJECTS = $(am_sunifdef_OBJECTS)
sunifdef_LDADD = $(LDADD)
sunifdef_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
......@@ -194,12 +195,13 @@ sunifdef_SOURCES = args.c args.h bool.h categorical.c categorical.h chew.c \
exception.h file_tree.c file_tree.h filesys.c filesys.h fs_nix.c fs_win.c \
if_control.c if_control.h io.c io.h line_despatch.c line_despatch.h line_edit.c \
line_edit.h main.c memory.c memory.h opts.h platform.h ptr_vector.c ptr_vector.h \
report.c report.h state_utils.c state_utils.h symbol_table.c symbol_table.h
report.c report.h state_utils.c state_utils.h symbol_table.c symbol_table.h \
string_util.c string_util.h
noinst_HEADERS = args.h bool.h categorical.h chew.h doxygen.h evaluator.h \
if_control.h io.h line_despatch.h line_edit.h memory.h platform.h ptr_vector.h \
state_utils.h symbol_table.h opts.h file_tree.h filesys.h exception.h dataset.h \
report.h
report.h string_util.h
all: all-am
......@@ -292,6 +294,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/report.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/state_utils.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symbol_table.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string_util.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
......
......@@ -494,7 +494,7 @@ usage_help(void)
#ifdef UNIX
#error VERSION not defined.
#endif
#define VERSION "3.1.3"
#define VERSION "4.0.0"
#endif
/*! Write version information about the program on \c stdout
*/
......
......@@ -48,6 +48,7 @@
#include "io.h"
#include "opts.h"
#include "bool.h"
#include "string_util.h"
#include <stdio.h>
#include <ctype.h>
......@@ -61,26 +62,6 @@
/* Helpers ***********************************************************/
/*! Count number of newline characters in string
*
* \param text Zero-terminated string.
* \returns Number of newline characters in text
*/
static size_t count_lines(char const *text)
{
size_t count = 0;
while(text != NULL)
{
text = strchr(text, '\n');
if (text!=NULL)
{
count++;
text += 1;
}
}
return count;
}
/*! Print an unmodified line to output with no complications
*/
static void
......
......@@ -39,9 +39,10 @@
#include "io.h"
#include "report.h"
#include "line_despatch.h"
#include "symbol_table.h"
#include "symbol_table.h"
#include "string_util.h"
#include <string.h>
/*!\ingroup line_edit_module, line_edit_interface, line_edit_internals
*\file line_edit.c
* This file implements the Line Edit module
......@@ -68,16 +69,26 @@
*
* The function does the editing work for \c keywordedit(). It ensures
* that there is sufficient capacity in the line-buffer to contain the
* replacement, extending the buffer if necessary.
* replacement, extending the buffer if necessary.
*
* If where contains more lines than what, what will be extended with
* newlines to match the number of lines in where.
*/
static void
tail_edit(char *where, const char *what)
{
size_t where_lines = count_lines(where);
size_t what_lines = count_lines(what);
char *what_extended = allocate(strlen(what) + what_lines - 1);
strcpy(what_extended, what);
for(size_t i=0; i<(where_lines-what_lines); i++) {
strcat(what_extended, "\n");
}
assert(GET_PUBLIC(io,line_start) <= where &&
where < GET_PUBLIC(io,line_end));
ensure_buf(strlen(what));
strcpy(where,what);
ensure_buf(strlen(what_extended));
strcpy(where,what_extended);
release((void**)(&what_extended));
}
/*@}*/
......@@ -97,7 +108,7 @@ void
delete_paren(char *lparen, char *rparen)
{
#if 0
if (*lparen == '(' && *rparen == ')' ) {
if (*lparen == '(' && *rparen == ')' ) {
if ((lparen[-1] == ' ' ||
lparen[-1] == '(' ||
lparen[1] == ' ' ||
......@@ -108,7 +119,7 @@ delete_paren(char *lparen, char *rparen)
rparen[1] == ' ' ||
rparen[1] == ')' ||
rparen[1] == '\n'))
{
*lparen = DELETEABLE_LPAREN;
*rparen = DELETEABLE_RPAREN;
......@@ -132,7 +143,7 @@ delete_paren(char *lparen, char *rparen)
void
restore_paren(void)
{
char *buf = GET_PUBLIC(io,line_start);
char *buf = GET_PUBLIC(io,line_start);
for ( ;*buf; ++buf) {
if (*buf == DELETEABLE_LPAREN) {
*buf = '(';
......@@ -157,7 +168,7 @@ cut_text(char *start, char *end)
/*!\ingroup line_edit_internals_state_utils */
/*@{*/
/*! The Line Edit module has no private state */
/*! The Line Edit module has no private state */
NO_PRIVATE_STATE(line_edit);
/*@}*/
......
/***************************************************************************
* Copyright (C) 2020 Qorvo Inc. *
* All rights reserved. *
* *
* Contributed originally by Koen Martens, koen.martens@qorvo.com *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* Neither the name of Qorvo Inc. nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS *
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED *
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,*
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF *
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
***************************************************************************/
#include <string.h>
/*!\ingroup string_util
*\file string_util.c
* This file implements string utilities
*/
size_t count_lines(char const *text)
{
size_t count = 0;
while(text != NULL)
{
text = strchr(text, '\n');
if (text!=NULL)
{
count++;
text += 1;
}
}
return count;
}
/*@}*/
/* EOF */
#ifndef STRING_UTIL_H
#define STRING_UTIL_H
/***************************************************************************
* Copyright (C) 2020 Qorvo Inc. *
* All rights reserved. *
* *
* Contributed originally by Koen Martens, koen.martens@qorvo.com *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* Neither the name of Qorvo Inc. nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS *
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED *
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,*
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF *
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
***************************************************************************/
#include <stdint.h>
/*! \ingroup string_util
* \file string_util.h
* This file provides string utilities
*/
/*! \addtogroup string_util */
/*@{*/
/*! Count number of newline characters in string
*
* \param text Zero-terminated string.
* \returns Number of newline characters in text
*/
size_t count_lines(char const *text);
/*@}*/
#endif /* EOF */
/**ARGS: -DFOO3 -kb */
/**SYSCODE: = 33 */
#if defined(FOO1)
foo1();
#elif defined(FOO2) || \
defined(FOO3) || \
defined(FOO4)
foo234();
#endif
/**ARGS: -DFOO3 -kb */
/**SYSCODE: = 33 */
#if defined(FOO1)
foo1();
#else
foo234();
#endif
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