Skip to content

Commit

Permalink
Merge pull request #2646 from masatake/readtags-fix-if-special-form
Browse files Browse the repository at this point in the history
dsl: fix `if' special form
  • Loading branch information
masatake committed Sep 14, 2020
2 parents dc02aee + 188e935 commit 23d50b5
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 1 deletion.
1 change: 1 addition & 0 deletions Tmain/readtags-sorter-if-sform.d/exit-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
11 changes: 11 additions & 0 deletions Tmain/readtags-sorter-if-sform.d/input.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
enum MUTEX_E { mutex_a, mutex_b, mutex };

#define mutex mutex

int mutex;

struct MUTEX_S {
int mutex;
};

typedef mutex int;
18 changes: 18 additions & 0 deletions Tmain/readtags-sorter-if-sform.d/output.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PATTERN_LENGTH_LIMIT 96 /0 for no limit/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 0.0.0 /717028d4/
MUTEX_E input.c /^enum MUTEX_E { mutex_a, mutex_b, mutex };$/;" g language:C file:
MUTEX_S input.c /^struct MUTEX_S {$/;" s language:C file:
mutex input.c /^ int mutex;$/;" m language:C struct:MUTEX_S typeref:typename:int file:
mutex input.c /^#define mutex /;" d language:C file:
mutex input.c /^enum MUTEX_E { mutex_a, mutex_b, mutex };$/;" e language:C enum:MUTEX_E file:
mutex input.c /^int mutex;$/;" v language:C typeref:typename:int
mutex input.c /^typedef mutex int;$/;" t language:C typeref:typename:int file:
mutex_a input.c /^enum MUTEX_E { mutex_a, mutex_b, mutex };$/;" e language:C enum:MUTEX_E file:
mutex_b input.c /^enum MUTEX_E { mutex_a, mutex_b, mutex };$/;" e language:C enum:MUTEX_E file:
41 changes: 41 additions & 0 deletions Tmain/readtags-sorter-if-sform.d/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh

# Copyright: 2020 Masatake YAMATO
# License: GPL-2

READTAGS=$3

. ../utils.sh

#V="valgrind --leak-check=full -v"
V=

if ! [ -x "${READTAGS}" ]; then
skip "no readtags"
fi

if ! ( "${READTAGS}" -h | grep -q -e -S ); then
skip "no sorter function in readtags"
fi

${READTAGS} -t output.tags -ne -S '(if (eq? $kind &kind)
0
(+
(if (or (eq? $kind "t"))
-4
(if (eq? $kind "v")
-3
(if (eq? $kind "d")
-2
(if (eq? $kind "e")
-1
0))))
(if (or (eq? &kind "t"))
4
(if (eq? &kind "v")
3
(if (eq? &kind "d")
2
(if (eq? &kind "e")
1
0))))))' mutex
Empty file.
5 changes: 5 additions & 0 deletions Tmain/readtags-sorter-if-sform.d/stdout-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mutex input.c /^typedef mutex int;$/;" kind:t file: language:C typeref:typename:int
mutex input.c /^int mutex;$/;" kind:v language:C typeref:typename:int
mutex input.c /^#define mutex /;" kind:d file: language:C
mutex input.c /^enum MUTEX_E { mutex_a, mutex_b, mutex };$/;" kind:e file: language:C enum:MUTEX_E
mutex input.c /^ int mutex;$/;" kind:m file: language:C struct:MUTEX_S typeref:typename:int
2 changes: 1 addition & 1 deletion dsl/dsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ static EsObject* sform_if (EsObject *args, DSLEnv *env)

o = es_car (args);
o = dsl_eval0 (o, env);
if (es_object_equal (o, es_false))
if (!es_object_equal (o, es_false))
return dsl_eval0 (es_car (es_cdr (args)), env);
else if (es_error_p (o))
return o;
Expand Down

0 comments on commit 23d50b5

Please sign in to comment.