Skip to content

Commit

Permalink
patch 8.2.2928: the evalfunc.c file is too big
Browse files Browse the repository at this point in the history
Problem:    The evalfunc.c file is too big.
Solution:   Move float related functionality to a separate file. (Yegappan
            Lakshmanan, closes #8287)
  • Loading branch information
yegappan authored and brammool committed Jun 2, 2021
1 parent a83d060 commit 01c798c
Show file tree
Hide file tree
Showing 14 changed files with 544 additions and 547 deletions.
2 changes: 2 additions & 0 deletions Filelist
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ SRC_ALL = \
src/fileio.c \
src/filepath.c \
src/findfile.c \
src/float.c \
src/fold.c \
src/getchar.c \
src/globals.h \
Expand Down Expand Up @@ -246,6 +247,7 @@ SRC_ALL = \
src/proto/fileio.pro \
src/proto/filepath.pro \
src/proto/findfile.pro \
src/proto/float.pro \
src/proto/fold.pro \
src/proto/getchar.pro \
src/proto/gui.pro \
Expand Down
1 change: 1 addition & 0 deletions src/Make_ami.mak
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ SRC += \
fileio.c \
filepath.c \
findfile.c \
float.c \
fold.c \
getchar.c \
hardcopy.c \
Expand Down
1 change: 1 addition & 0 deletions src/Make_cyg_ming.mak
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ OBJ = \
$(OUTDIR)/fileio.o \
$(OUTDIR)/filepath.o \
$(OUTDIR)/findfile.o \
$(OUTDIR)/float.o \
$(OUTDIR)/fold.o \
$(OUTDIR)/getchar.o \
$(OUTDIR)/gui_xim.o \
Expand Down
4 changes: 4 additions & 0 deletions src/Make_mvc.mak
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ OBJ = \
$(OUTDIR)\fileio.obj \
$(OUTDIR)\filepath.obj \
$(OUTDIR)\findfile.obj \
$(OUTDIR)\float.obj \
$(OUTDIR)\fold.obj \
$(OUTDIR)\getchar.obj \
$(OUTDIR)\gui_xim.obj \
Expand Down Expand Up @@ -1599,6 +1600,8 @@ $(OUTDIR)/filepath.obj: $(OUTDIR) filepath.c $(INCL)

$(OUTDIR)/findfile.obj: $(OUTDIR) findfile.c $(INCL)

$(OUTDIR)/float.obj: $(OUTDIR) float.c $(INCL)

$(OUTDIR)/fold.obj: $(OUTDIR) fold.c $(INCL)

$(OUTDIR)/getchar.obj: $(OUTDIR) getchar.c $(INCL)
Expand Down Expand Up @@ -1935,6 +1938,7 @@ proto.h: \
proto/fileio.pro \
proto/filepath.pro \
proto/findfile.pro \
proto/float.pro \
proto/getchar.pro \
proto/gui_xim.pro \
proto/hardcopy.pro \
Expand Down
5 changes: 5 additions & 0 deletions src/Make_vms.mms
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ SRC = \
fileio.c \
filepath.c, \
findfile.c \
float.c \
fold.c \
getchar.c \
gui_xim.c \
Expand Down Expand Up @@ -460,6 +461,7 @@ OBJ = \
fileio.obj \
filepath.obj \
findfile.obj \
float.obj \
fold.obj \
getchar.obj \
gui_xim.obj \
Expand Down Expand Up @@ -860,6 +862,9 @@ findfile.obj : findfile.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h \
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
errors.h globals.h
float.obj : float.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \
[.proto]gui_beval.pro option.h ex_cmds.h proto.h errors.h globals.h
fold.obj : fold.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \
[.proto]gui_beval.pro option.h ex_cmds.h proto.h errors.h globals.h
Expand Down
29 changes: 22 additions & 7 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,8 @@ CClink = $(CC)
# Select the architecture supported. Default is to build for the current
# platform. Use "both" for a universal binary. That probably doesn't work
# when including Perl, Python, etc.
#CONF_OPT_DARWIN = --with-mac-arch=i386
# NOTE: ppc probably doesn't work anymore,
#CONF_OPT_DARWIN = --with-mac-arch=intel
#CONF_OPT_DARWIN = --with-mac-arch=ppc
#CONF_OPT_DARWIN = --with-mac-arch=both

Expand Down Expand Up @@ -436,6 +437,8 @@ CClink = $(CC)
# PYTHON
# Uncomment lines here when you want to include the Python interface.
# This requires at least "normal" features, "tiny" and "small" don't work.
# Python 3 is preferred, Python 2 (often referred to as "Python") has been
# deprecated for a long time.
# NOTE: This may cause threading to be enabled, which has side effects (such
# as using different libraries and debugging becomes more difficult).
# For Python3 support make a symbolic link in /usr/local/bin:
Expand Down Expand Up @@ -463,7 +466,7 @@ CClink = $(CC)
# TCL
# Uncomment this when you want to include the Tcl interface.
# First one is for static linking, second one for dynamic loading.
#CONF_OPT_TCL = --enable-tclinterp
CONF_OPT_TCL = --enable-tclinterp
#CONF_OPT_TCL = --enable-tclinterp=dynamic
#CONF_OPT_TCL = --enable-tclinterp --with-tclsh=tclsh8.4

Expand Down Expand Up @@ -690,16 +693,18 @@ LINT_OPTIONS = -beprxzF
# PROFILE_CFLAGS=-g -O0 --coverage -DWE_ARE_PROFILING -DUSE_GCOV_FLUSH


# Uncomment one of the next two lines to compile Vim with the
# address sanitizer (asan) or with the undefined sanitizer. Works with gcc.
# Uncomment the next lines to compile Vim with the address sanitizer (asan) and
# with the undefined sanitizer. Works with gcc.
# You should also use -DEXITFREE to avoid false reports.
# May make Vim twice as slow. Errors are reported on stderr.
# More at: https://code.google.com/p/address-sanitizer/
# Useful environment variables:
# $ export ASAN_OPTIONS="print_stacktrace=1 log_path=asan"
# $ export LSAN_OPTIONS="suppressions=`pwd`/testdir/lsan-suppress.txt"
# When running tests output can be found in testdir/asan.*
#SANITIZER_CFLAGS = -g -O0 -fsanitize=address -fno-omit-frame-pointer
#SANITIZER_CFLAGS = -g -O0 -fsanitize=undefined -fno-omit-frame-pointer
#SANITIZER_CFLAGS = -g -O0 -fsanitize-recover=all \
# -fsanitize=address -fsanitize=undefined \
# -fno-omit-frame-pointer

# Similarly when compiling with clang and using ubsan.
# $ export UBSAN_OPTIONS="print_stacktrace=1 log_path=ubsan"
Expand Down Expand Up @@ -979,7 +984,7 @@ SANITIZER_LIBS = $(SANITIZER_CFLAGS)

# The value of QUOTESED comes from auto/config.mk.
# Uncomment the next line to use the default value.
# QUOTESED = sed -e 's/[\\"]/\\&/g' -e 's/\\"/"/' -e 's/\\";$$/";/'
# QUOTESED = sed -e 's/[\\"]/\\&/g' -e 's/\\"/"/' -e 's/\\";$$/";/' -e 's/ */ /g'

##################### end of system specific lines ################### }}}

Expand Down Expand Up @@ -1621,6 +1626,7 @@ BASIC_SRC = \
fileio.c \
filepath.c \
findfile.c \
float.c \
fold.c \
getchar.c \
gui_xim.c \
Expand Down Expand Up @@ -1775,6 +1781,7 @@ OBJ_COMMON = \
objects/fileio.o \
objects/filepath.o \
objects/findfile.o \
objects/float.o \
objects/fold.o \
objects/getchar.o \
objects/gui_xim.o \
Expand Down Expand Up @@ -1945,6 +1952,7 @@ PRO_AUTO = \
fileio.pro \
filepath.pro \
findfile.pro \
float.pro \
fold.pro \
getchar.pro \
gui_xim.pro \
Expand Down Expand Up @@ -3247,6 +3255,9 @@ objects/filepath.o: filepath.c
objects/findfile.o: findfile.c
$(CCC) -o $@ findfile.c

objects/float.o: float.c
$(CCC) -o $@ float.c

objects/fold.o: fold.c
$(CCC) -o $@ fold.c

Expand Down Expand Up @@ -3838,6 +3849,10 @@ objects/findfile.o: findfile.c vim.h protodef.h auto/config.h feature.h os_unix.
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h errors.h globals.h
objects/float.o: float.c vim.h protodef.h auto/config.h feature.h \
os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h errors.h globals.h
objects/fold.o: fold.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
Expand Down
1 change: 1 addition & 0 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ locale.c | locale/language handling
map.c | mapping and abbreviations
mark.c | marks
match.c | highlight matching
float.c | floating point functions
mbyte.c | multi-byte character handling
memfile.c | storing lines for buffers in a swapfile
memline.c | storing lines for buffers in memory
Expand Down
37 changes: 0 additions & 37 deletions src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -5155,43 +5155,6 @@ string_quote(char_u *str, int function)
return s;
}

#if defined(FEAT_FLOAT) || defined(PROTO)
/*
* Convert the string "text" to a floating point number.
* This uses strtod(). setlocale(LC_NUMERIC, "C") has been used to make sure
* this always uses a decimal point.
* Returns the length of the text that was consumed.
*/
int
string2float(
char_u *text,
float_T *value) // result stored here
{
char *s = (char *)text;
float_T f;

// MS-Windows does not deal with "inf" and "nan" properly.
if (STRNICMP(text, "inf", 3) == 0)
{
*value = INFINITY;
return 3;
}
if (STRNICMP(text, "-inf", 3) == 0)
{
*value = -INFINITY;
return 4;
}
if (STRNICMP(text, "nan", 3) == 0)
{
*value = NAN;
return 3;
}
f = strtod(s, &s);
*value = f;
return (int)((char_u *)s - text);
}
#endif

/*
* Convert the specified byte index of line 'lnum' in buffer 'buf' to a
* character index. Works only for loaded buffers. Returns -1 on failure.
Expand Down

0 comments on commit 01c798c

Please sign in to comment.