From aaa76f3e2d0e72b3174cdadb39a90cc12fb555c2 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Wed, 2 Oct 2019 11:08:53 +0200 Subject: [PATCH] build a test driver for the unac function --- src/testmains/Makefile.am | 4 +++- src/testmains/trunac.cpp | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/testmains/Makefile.am b/src/testmains/Makefile.am index 1c91a23c..3c2e6dd9 100644 --- a/src/testmains/Makefile.am +++ b/src/testmains/Makefile.am @@ -37,7 +37,7 @@ AM_CPPFLAGS = -Wall -Wno-unused -std=c++11 \ -D_GNU_SOURCE \ $(DEFS) -noinst_PROGRAMS = textsplit utf8iter fstreewalk rclconfig hldata +noinst_PROGRAMS = textsplit utf8iter fstreewalk rclconfig hldata unac textsplit_SOURCES = trtextsplit.cpp textsplit_LDADD = ../librecoll.la @@ -54,3 +54,5 @@ rclconfig_LDADD = ../librecoll.la hldata_SOURCES = trhldata.cpp hldata_LDADD = ../librecoll.la +unac_SOURCES = trunac.cpp +unac_LDADD = ../librecoll.la diff --git a/src/testmains/trunac.cpp b/src/testmains/trunac.cpp index 23bb4b32..36a1b7ba 100644 --- a/src/testmains/trunac.cpp +++ b/src/testmains/trunac.cpp @@ -1,3 +1,22 @@ +/* Copyright (C) 2017-2019 J.F.Dockes + * + * License: GPL 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ #include #include #include @@ -85,8 +104,10 @@ int main(int argc, char **argv) const char *encoding = *argv++; argc--; string ifn = *argv++; argc--; - if (!ifn.compare("stdin")) + if (!ifn.compare("stdin") || !ifn.compare("-")) { + // file_read interprets an empty fn as "use stdin" ifn.clear(); + } const char *ofn = *argv++; argc--; string reason; @@ -104,7 +125,7 @@ int main(int argc, char **argv) } int fd; - if (strcmp(ofn, "stdout")) { + if (strcmp(ofn, "stdout") && strcmp(ofn, "-")) { fd = open(ofn, O_CREAT|O_EXCL|O_WRONLY, 0666); } else { fd = 1;