From 7ab738957c8651706fd33f0783d3bc821f2bc904 Mon Sep 17 00:00:00 2001 From: Daniel Aarno Date: Thu, 24 Aug 2017 23:13:13 +0100 Subject: [PATCH] Quick fix for ZshCompletionOutput test The test was failing because elipsis changed from "..." to "... ". This is a quick and dirty fix and should be cleaned up. Also updated copyright notice --- COPYING | 2 ++ include/tclap/ZshCompletionOutput.h | 6 ++++++ tests/test85.out | 10 +++++++++- tests/test85.sh | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/COPYING b/COPYING index 987be0c..d573236 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,8 @@ Copyright (c) 2003 Michael E. Smoot +Copyright (c) 2004 Daniel Aarno +Copyright (c) 2017 Google Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/include/tclap/ZshCompletionOutput.h b/include/tclap/ZshCompletionOutput.h index 0b37fc7..6da4e30 100644 --- a/include/tclap/ZshCompletionOutput.h +++ b/include/tclap/ZshCompletionOutput.h @@ -231,6 +231,12 @@ inline void ZshCompletionOutput::printOption(Arg* a, std::string mutex) if ( a->isValueRequired() ) { std::string arg = a->shortID(); + // Example arg: "[-A ] ... " + size_t pos = arg.rfind(" ... "); + if (pos != std::string::npos) { + arg.erase(pos); + } + arg.erase(0, arg.find_last_of(theDelimiter) + 1); if ( arg.at(arg.length()-1) == ']' ) arg.erase(arg.length()-1); diff --git a/tests/test85.out b/tests/test85.out index 89fe101..87a7b2c 100644 --- a/tests/test85.out +++ b/tests/test85.out @@ -1,2 +1,10 @@ -This feature appears broken! +#compdef test25 +# test25 version 0.99 + +_arguments -s -S \ + '*(-A --sA)'{-A,--sA}'[exist Test A]:integer' \ + '(-s --Bs -B --sB)'{-B,--sB}'[exist Test B]' \ + '(-s --Bs -B --sB)'{-s,--Bs}'[string test]:string' \ + '(-)--version[displays version information and exits]' \ + '(-)'{-h,--help}'[displays usage information and exits]' diff --git a/tests/test85.sh b/tests/test85.sh index 964bb75..4816a55 100755 --- a/tests/test85.sh +++ b/tests/test85.sh @@ -5,7 +5,7 @@ # updated ../examples/test25 -h > tmp.out 2>&1 -if cmp -s tmp.out $srcdir/test82.out; then +if cmp -s tmp.out $srcdir/test85.out; then exit 0 else exit 1