Revision: 65245
http://sourceforge.net/p/brlcad/code/65245
Author: n_reed
Date: 2015-06-10 17:26:54 +0000 (Wed, 10 Jun 2015)
Log Message:
-----------
sync from trunk
Modified Paths:
--------------
brlcad/branches/brep-debug/CMakeLists.txt
brlcad/branches/brep-debug/TODO
brlcad/branches/brep-debug/doc/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/articles/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/articles/en/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/articles/hy/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/articles/it/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/articles/ru/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/books/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/books/en/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/lessons/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/lessons/en/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/lessons/es/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/presentations/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/presentations/en/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/specifications/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/specifications/en/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/system/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/system/man1/en/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/system/man1/en/bwmod.xml
brlcad/branches/brep-debug/doc/docbook/system/man1/en/bwstat.xml
brlcad/branches/brep-debug/doc/docbook/system/man3/en/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/system/man5/en/CMakeLists.txt
brlcad/branches/brep-debug/doc/docbook/system/mann/en/CMakeLists.txt
brlcad/branches/brep-debug/include/analyze.h
brlcad/branches/brep-debug/include/bu/color.h
brlcad/branches/brep-debug/include/bu/opt.h
brlcad/branches/brep-debug/misc/CMake/BRLCAD_Summary.cmake
brlcad/branches/brep-debug/misc/CMake/DocBook.cmake
brlcad/branches/brep-debug/src/conv/CMakeLists.txt
brlcad/branches/brep-debug/src/conv/gcv/gcv.cpp
brlcad/branches/brep-debug/src/external/README
brlcad/branches/brep-debug/src/libbu/booleanize.c
brlcad/branches/brep-debug/src/libbu/color.c
brlcad/branches/brep-debug/src/libbu/opt.c
brlcad/branches/brep-debug/src/libbu/tests/CMakeLists.txt
brlcad/branches/brep-debug/src/libbu/tests/opt.c
brlcad/branches/brep-debug/src/libgcv/conv/fastgen4/fastgen4_write.cpp
brlcad/branches/brep-debug/src/libicv/crop.c
brlcad/branches/brep-debug/src/util/bwmod.c
brlcad/branches/brep-debug/src/util/bwstat.c
brlcad/branches/brep-debug/src/util/dsp_add_opt.c
brlcad/branches/brep-debug/src/util/gencolor.c
Added Paths:
-----------
brlcad/branches/brep-debug/doc/code_review.txt
brlcad/branches/brep-debug/doc/docbook/resources/brlcad/wordpress.xsl.in
brlcad/branches/brep-debug/src/conv/csg/
Property Changed:
----------------
brlcad/branches/brep-debug/
brlcad/branches/brep-debug/src/libged/polyclip.cpp
Index: brlcad/branches/brep-debug
===================================================================
--- brlcad/branches/brep-debug 2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug 2015-06-10 17:26:54 UTC (rev 65245)
Property changes on: brlcad/branches/brep-debug
___________________________________________________________________
Modified: svn:mergeinfo
## -3,4 +3,4 ##
/brlcad/branches/cmake:43219
/brlcad/branches/gct:62423-62425
/brlcad/branches/osg:62110-62113
-/brlcad/trunk:61364-65164
+/brlcad/trunk:61364-65244
\ No newline at end of property
Modified: brlcad/branches/brep-debug/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/CMakeLists.txt 2015-06-10 17:01:40 UTC (rev
65244)
+++ brlcad/branches/brep-debug/CMakeLists.txt 2015-06-10 17:26:54 UTC (rev
65245)
@@ -1365,6 +1365,9 @@
CMAKE_DEPENDENT_OPTION(BRLCAD_EXTRADOCS_HTML "Build MAN page output from
DocBook documentation" ON "BRLCAD_EXTRADOCS" OFF)
mark_as_advanced(BRLCAD_EXTRADOCS_HTML)
+CMAKE_DEPENDENT_OPTION(BRLCAD_EXTRADOCS_PHP "Build MAN page output from
DocBook documentation" OFF "BRLCAD_EXTRADOCS" OFF)
+mark_as_advanced(BRLCAD_EXTRADOCS_PHP)
+
# Normally, we'll turn on man page output by default, but there is
# no point in doing man page output for a Visual Studio build - the
# files aren't useful and it *seriously* increases the target build
Modified: brlcad/branches/brep-debug/TODO
===================================================================
--- brlcad/branches/brep-debug/TODO 2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/TODO 2015-06-10 17:26:54 UTC (rev 65245)
@@ -56,6 +56,10 @@
THESE ARE UNSCHEDULED BACKLOG TASKS
-----------------------------------
+* importer for LS-DYNA .k keyword files. they support a variety of
+ geometry constructs. their spec is freely available online. no
+ existing libs are known.
+
* analyze output that can characterize how much error or any other
issues identified in a given object. this is primarily intended for
bot, nmg, and brep nurbs models, to report the amount of spatial
Modified: brlcad/branches/brep-debug/doc/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/CMakeLists.txt 2015-06-10 17:01:40 UTC
(rev 65244)
+++ brlcad/branches/brep-debug/doc/CMakeLists.txt 2015-06-10 17:26:54 UTC
(rev 65245)
@@ -27,6 +27,7 @@
benchmark.tr
brep.txt
BRL-CAD.bib
+ code_review.txt
cvs.txt
description.txt
ged.tr
Copied: brlcad/branches/brep-debug/doc/code_review.txt (from rev 65244,
brlcad/trunk/doc/code_review.txt)
===================================================================
--- brlcad/branches/brep-debug/doc/code_review.txt
(rev 0)
+++ brlcad/branches/brep-debug/doc/code_review.txt 2015-06-10 17:26:54 UTC
(rev 65245)
@@ -0,0 +1,48 @@
+BRL-CAD Code Review
+===================
+
+...what to look for during a review...
+
+Legal:
+ * proper copyright statement and compatible license?
+ * any indication contribution disagrees with copyright assignment?
+ * if incorporating 3rd party code, prefer bsd/mit-style options
+
+Architecture:
+ * proper location in hierarchy?
+ * proper file name(s)?
+ * is a dependency being introduced?
+ * is a cyclic dependency being introduced?
+ * are any global variables being introduced?
+
+Design:
+ * is public API minimized?
+ * is a platform symbol being used?
+ * does the change reduce or violate modularity?
+ * is the approach being taken reasonable?
+ * is the code easy to understand?
+
+Testing:
+ * compiles cleanly?
+ * are warnings handled cleanly?
+ * any blatant logic errors?
+ * are all data inputs checked properly, sanitized?
+ * if fixing a bug more than once, is there a test?
+ * is a unit test warranted?
+ * are there major robustness issues?
+
+Documentation:
+ * if publicly visible, is NEWS updated?
+ * if public API changed, is CHANGES updated?
+ * if public API introduced, does every symbol have a comment?
+ * if interface changed, are man page or other docs updated?
+ * are numeric constants documented?
+ * is suspicious, complex, risky code commented?
+
+Code:
+ * conforms with style and coding standards?
+ * proper indentation, formatting, whitespace?
+ * are symbol names consistent?
+ * is duplication being introduced, refactoring warranted?
+ * is there undocumented dead / commented-out code?
+ * can any code be replaced with library calls?
Modified: brlcad/branches/brep-debug/doc/docbook/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/CMakeLists.txt 2015-06-10
17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/CMakeLists.txt 2015-06-10
17:26:54 UTC (rev 65245)
@@ -11,13 +11,16 @@
string(REPLACE " " "%20" DOCBOOK_SOURCE_DIR "${CMAKE_SOURCE_DIR}")
# Common stylesheets for all DocBook sources
-if(BRLCAD_EXTRADOCS_HTML OR BRLCAD_EXTRADOCS_PDF OR BRLCAD_EXTRADOCS_MAN)
+if(BRLCAD_EXTRADOCS_HTML OR BRLCAD_EXTRADOCS_PDF OR BRLCAD_EXTRADOCS_MAN OR
BRLCAD_EXTRADOCS_PHP)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/brlcad/brlcad-common.xsl.in
${CMAKE_CURRENT_BINARY_DIR}/resources/brlcad/brlcad-common.xsl)
# Fonts definition
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/brlcad/brlcad-fonts.xsl.in
${CMAKE_CURRENT_BINARY_DIR}/resources/brlcad/brlcad-fonts.xsl)
-endif(BRLCAD_EXTRADOCS_HTML OR BRLCAD_EXTRADOCS_PDF OR BRLCAD_EXTRADOCS_MAN)
+ # Wordpress
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/brlcad/wordpress.xsl.in
+ ${CMAKE_CURRENT_BINARY_DIR}/resources/brlcad/wordpress.xsl)
+endif(BRLCAD_EXTRADOCS_HTML OR BRLCAD_EXTRADOCS_PDF OR BRLCAD_EXTRADOCS_MAN OR
BRLCAD_EXTRADOCS_PHP)
# Files for PDF products
if(BRLCAD_EXTRADOCS_PDF)
@@ -54,6 +57,11 @@
add_custom_target(doc_html DEPENDS ${BRLCAD_EXTRADOCS_HTML_TARGETS})
set_target_properties(doc_html PROPERTIES FOLDER "DocBook")
endif(BRLCAD_EXTRADOCS_HTML)
+if(BRLCAD_EXTRADOCS_PHP)
+ get_property(BRLCAD_EXTRADOCS_PHP_TARGETS GLOBAL PROPERTY
BRLCAD_EXTRADOCS_PHP_TARGETS)
+ add_custom_target(doc_php DEPENDS ${BRLCAD_EXTRADOCS_PHP_TARGETS})
+ set_target_properties(doc_php PROPERTIES FOLDER "DocBook")
+endif(BRLCAD_EXTRADOCS_PHP)
if(BRLCAD_EXTRADOCS_MAN)
get_property(BRLCAD_EXTRADOCS_MAN_TARGETS GLOBAL PROPERTY
BRLCAD_EXTRADOCS_MAN_TARGETS)
add_custom_target(doc_man DEPENDS ${BRLCAD_EXTRADOCS_MAN_TARGETS})
@@ -64,13 +72,14 @@
add_custom_target(doc_pdf DEPENDS ${BRLCAD_EXTRADOCS_PDF_TARGETS})
set_target_properties(doc_pdf PROPERTIES FOLDER "DocBook")
endif(BRLCAD_EXTRADOCS_PDF)
-if(BRLCAD_EXTRADOCS_HTML OR BRLCAD_EXTRADOCS_MAN OR BRLCAD_EXTRADOCS_PDF)
+if(BRLCAD_EXTRADOCS_HTML OR BRLCAD_EXTRADOCS_MAN OR BRLCAD_EXTRADOCS_PDF OR
BRLCAD_EXTRADOCS_PHP)
add_custom_target(doc_all DEPENDS
${BRLCAD_EXTRADOCS_HTML_TARGETS}
- ${BRLCAD_EXTRADOCS_MAN_TARGETS}
+ ${BRLCAD_EXTRADOCS_PHP_TARGETS}
+ ${BRLCAD_EXTRADOCS_MAN_TARGETS}
${BRLCAD_EXTRADOCS_PDF_TARGETS})
set_target_properties(doc_all PROPERTIES FOLDER "DocBook")
-endif(BRLCAD_EXTRADOCS_HTML OR BRLCAD_EXTRADOCS_MAN OR BRLCAD_EXTRADOCS_PDF)
+endif(BRLCAD_EXTRADOCS_HTML OR BRLCAD_EXTRADOCS_MAN OR BRLCAD_EXTRADOCS_PDF OR
BRLCAD_EXTRADOCS_PHP)
CMAKEFILES(README fop.xconf.in log4j.properties resources)
CMAKEFILES(README.DB_authors_notes)
Modified: brlcad/branches/brep-debug/doc/docbook/articles/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/articles/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/articles/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -4,6 +4,11 @@
${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-article-xhtml-stylesheet.xsl)
endif(BRLCAD_EXTRADOCS_HTML)
+if(BRLCAD_EXTRADOCS_PHP)
+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../resources/brlcad/brlcad-article-xhtml-stylesheet.xsl.in
+
${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-article-xhtml-stylesheet.xsl)
+endif(BRLCAD_EXTRADOCS_PHP)
+
# Files for PDF products
if(BRLCAD_EXTRADOCS_PDF)
# Style sheet for XSLT transformation to PDF
@@ -14,6 +19,7 @@
# For HTML and FO (FO is an intermediate file used in the
# XML->PDF transformation) we use variables to hold the full
# stylesheet path.
+set(XSL_PHP_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/wordpress.xsl")
set(XSL_XHTML_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-article-xhtml-stylesheet.xsl")
set(XSL_FO_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-article-fo-stylesheet.xsl")
Modified: brlcad/branches/brep-debug/doc/docbook/articles/en/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/articles/en/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/articles/en/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -155,6 +155,7 @@
ADD_DOC(docbook_articles_EN_IMAGES html/articles/en/images)
DOCBOOK_TO_HTML(article docbook_articles_EN html/articles/en
docbook_articles_EN_IMAGES_cp)
+DOCBOOK_TO_PHP(article docbook_articles_EN html/articles/en
docbook_articles_EN_IMAGES_cp)
if(BRLCAD_EXTRADOCS_PDF)
DOCBOOK_TO_PDF(article docbook_articles_EN pdf/articles/en
docbook_articles_EN_IMAGES_cp)
Modified: brlcad/branches/brep-debug/doc/docbook/articles/hy/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/articles/hy/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/articles/hy/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -3,6 +3,7 @@
)
DOCBOOK_TO_HTML(article docbook_articles_HY html/articles/hy "")
+DOCBOOK_TO_PHP(article docbook_articles_HY html/articles/hy "")
if(BRLCAD_EXTRADOCS_PDF)
DOCBOOK_TO_PDF(article docbook_articles_HY pdf/articles/hy "")
Modified: brlcad/branches/brep-debug/doc/docbook/articles/it/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/articles/it/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/articles/it/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -16,6 +16,7 @@
ADD_DOC(docbook_articles_IT_IMAGES html/articles/it/images)
DOCBOOK_TO_HTML(article docbook_articles_IT html/articles/it
docbook_articles_IT_IMAGES_cp)
+DOCBOOK_TO_PHP(article docbook_articles_IT html/articles/it
docbook_articles_IT_IMAGES_cp)
if(BRLCAD_EXTRADOCS_PDF)
DOCBOOK_TO_PDF(article docbook_articles_IT pdf/articles/it
docbook_articles_IT_IMAGES_cp)
Modified: brlcad/branches/brep-debug/doc/docbook/articles/ru/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/articles/ru/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/articles/ru/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -3,6 +3,7 @@
)
DOCBOOK_TO_HTML(article docbook_articles_RU html/articles/ru "")
+DOCBOOK_TO_PHP(article docbook_articles_RU html/articles/ru "")
if(BRLCAD_EXTRADOCS_PDF)
DOCBOOK_TO_PDF(article docbook_articles_RU pdf/articles/ru "")
Modified: brlcad/branches/brep-debug/doc/docbook/books/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/books/CMakeLists.txt 2015-06-10
17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/books/CMakeLists.txt 2015-06-10
17:26:54 UTC (rev 65245)
@@ -4,6 +4,11 @@
${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-book-xhtml-stylesheet.xsl)
endif(BRLCAD_EXTRADOCS_HTML)
+if(BRLCAD_EXTRADOCS_PHP)
+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../resources/brlcad/brlcad-book-xhtml-stylesheet.xsl.in
+
${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-book-xhtml-stylesheet.xsl)
+endif(BRLCAD_EXTRADOCS_PHP)
+
# Files for PDF products
if(BRLCAD_EXTRADOCS_PDF)
# Style sheet for XSLT transformation to PDF
@@ -14,6 +19,7 @@
# For HTML and FO (FO is an intermediate file used in the
# XML->PDF transformation) we use variables to hold the full
# stylesheet path.
+set(XSL_PHP_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/wordpress.xsl")
set(XSL_XHTML_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-book-xhtml-stylesheet.xsl")
set(XSL_FO_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-book-fo-stylesheet.xsl")
Modified: brlcad/branches/brep-debug/doc/docbook/books/en/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/books/en/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/books/en/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -60,6 +60,7 @@
BRL-CAD_Tutorial_Series-VolumeIV.xml
)
DOCBOOK_TO_HTML(book docbook_books_EN html/books/en docbook_books_EN_IMAGES_cp)
+DOCBOOK_TO_PHP(book docbook_books_EN html/books/en docbook_books_EN_IMAGES_cp)
# The PDFs need some special logic to generate custom
# covers.
Modified: brlcad/branches/brep-debug/doc/docbook/lessons/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/lessons/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/lessons/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -3,6 +3,10 @@
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../resources/brlcad/brlcad-lesson-xhtml-stylesheet.xsl.in
${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-lesson-xhtml-stylesheet.xsl)
endif(BRLCAD_EXTRADOCS_HTML)
+if(BRLCAD_EXTRADOCS_PHP)
+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../resources/brlcad/brlcad-lesson-xhtml-stylesheet.xsl.in
+
${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-lesson-xhtml-stylesheet.xsl)
+endif(BRLCAD_EXTRADOCS_PHP)
# Files for PDF products
if(BRLCAD_EXTRADOCS_PDF)
@@ -14,6 +18,7 @@
# For HTML and FO (FO is an intermediate file used in the
# XML->PDF transformation) we use variables to hold the full
# stylesheet path.
+set(XSL_PHP_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/wordpress.xsl")
set(XSL_XHTML_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-lesson-xhtml-stylesheet.xsl")
set(XSL_FO_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-lesson-fo-stylesheet.xsl")
Modified: brlcad/branches/brep-debug/doc/docbook/lessons/en/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/lessons/en/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/lessons/en/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -133,6 +133,7 @@
ADD_DOC(docbook_lessons_EN_IMAGES html/lessons/en/images)
DOCBOOK_TO_HTML(lesson docbook_lessons_EN html/lessons/en
docbook_lessons_EN_IMAGES_cp)
+DOCBOOK_TO_PHP(lesson docbook_lessons_EN html/lessons/en
docbook_lessons_EN_IMAGES_cp)
DOCBOOK_TO_PDF(lesson docbook_lessons_EN pdf/lessons/en
docbook_lessons_EN_IMAGES_cp)
# Local Variables:
Modified: brlcad/branches/brep-debug/doc/docbook/lessons/es/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/lessons/es/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/lessons/es/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -129,6 +129,7 @@
ADD_DOC(docbook_lessons_ES_IMAGES html/lessons/es/images)
DOCBOOK_TO_HTML(lesson_ES docbook_lessons_ES html/lessons/es
docbook_lessons_ES_IMAGES_cp)
+DOCBOOK_TO_PHP(lesson_ES docbook_lessons_ES html/lessons/es
docbook_lessons_ES_IMAGES_cp)
DOCBOOK_TO_PDF(lesson_ES docbook_lessons_ES pdf/lessons/es
docbook_lessons_ES_IMAGES_cp)
# Local Variables:
Modified: brlcad/branches/brep-debug/doc/docbook/presentations/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/presentations/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/presentations/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -4,6 +4,11 @@
${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-presentation-xhtml-stylesheet.xsl)
endif(BRLCAD_EXTRADOCS_HTML)
+if(BRLCAD_EXTRADOCS_PHP)
+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../resources/brlcad/brlcad-presentation-xhtml-stylesheet.xsl.in
+
${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-presentation-xhtml-stylesheet.xsl)
+endif(BRLCAD_EXTRADOCS_PHP)
+
# Files for PDF products
if(BRLCAD_EXTRADOCS_PDF)
# Style sheet for XSLT transformation to PDF
@@ -14,6 +19,7 @@
# For HTML and FO (FO is an intermediate file used in the
# XML->PDF transformation) we use variables to hold the full
# stylesheet path.
+set(XSL_PHP_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/wordpress.xsl")
set(XSL_XHTML_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-presentation-xhtml-stylesheet.xsl")
set(XSL_FO_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-presentation-fo-stylesheet.xsl")
Modified: brlcad/branches/brep-debug/doc/docbook/presentations/en/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/presentations/en/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/presentations/en/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -18,6 +18,7 @@
ADD_DOC(docbook_presentations_EN_IMAGES html/presentations/en/images)
DOCBOOK_TO_HTML(presentation docbook_presentations_EN html/presentations/en
docbook_presentations_EN_IMAGES_cp)
+DOCBOOK_TO_PHP(presentation docbook_presentations_EN html/presentations/en
docbook_presentations_EN_IMAGES_cp)
DOCBOOK_TO_PDF(presentation docbook_presentations_EN pdf/presentations/en
docbook_presentations_EN_IMAGES_cp)
# Local Variables:
Copied:
brlcad/branches/brep-debug/doc/docbook/resources/brlcad/wordpress.xsl.in (from
rev 65244, brlcad/trunk/doc/docbook/resources/brlcad/wordpress.xsl.in)
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/resources/brlcad/wordpress.xsl.in
(rev 0)
+++ brlcad/branches/brep-debug/doc/docbook/resources/brlcad/wordpress.xsl.in
2015-06-10 17:26:54 UTC (rev 65245)
@@ -0,0 +1,28 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+ <!-- Include other stylesheets -->
+ <xsl:import
href="file:///@DOCBOOK_BINARY_DIR@/doc/docbook/resources/other/standard/xsl/xhtml-1_1/docbook.xsl"/>
+
+ <xsl:template match="*" mode="process.root">
+ <xsl:variable name="doc" select="self::*"/>
+ <xsl:processing-instruction name="php">
+ require('wp-blog-header.php');
+ class MyPost { var $post_title = "<xsl:apply-templates select="$doc"
mode="object.title.markup.textonly"/>"; }
+ $wp_query->is_home = false;
+ $wp_query->is_single = true;
+ $wp_query->queried_object = new MyPost();
+ get_header();
+ </xsl:processing-instruction>
+ <div id="content" class="narrowcolumn" role="main">
+ <xsl:apply-templates select="."/>
+ </div>
+ <xsl:processing-instruction name="php">
+ get_sidebar();
+ get_footer();
+
+ </xsl:processing-instruction>
+ </xsl:template>
+
+</xsl:stylesheet>
+
Modified: brlcad/branches/brep-debug/doc/docbook/specifications/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/specifications/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/specifications/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -4,6 +4,11 @@
${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-specification-xhtml-stylesheet.xsl)
endif(BRLCAD_EXTRADOCS_HTML)
+if(BRLCAD_EXTRADOCS_PHP)
+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../resources/brlcad/brlcad-specification-xhtml-stylesheet.xsl.in
+
${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-specification-xhtml-stylesheet.xsl)
+endif(BRLCAD_EXTRADOCS_PHP)
+
# Files for PDF products
if(BRLCAD_EXTRADOCS_PDF)
# Style sheet for XSLT transformation to PDF
@@ -14,6 +19,7 @@
# For HTML and FO (FO is an intermediate file used in the
# XML->PDF transformation) we use variables to hold the full
# stylesheet path.
+set(XSL_PHP_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/wordpress.xsl")
set(XSL_XHTML_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-specification-xhtml-stylesheet.xsl")
set(XSL_FO_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-specification-fo-stylesheet.xsl")
Modified:
brlcad/branches/brep-debug/doc/docbook/specifications/en/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/specifications/en/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/specifications/en/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -3,7 +3,7 @@
)
DOCBOOK_TO_HTML(specification docbook_specifications_EN html/specifications/en
"")
-
+DOCBOOK_TO_PHP(specification docbook_specifications_EN html/specifications/en
"")
DOCBOOK_TO_PDF(specification docbook_specifications_EN pdf/specifications/en
"")
# Local Variables:
Modified: brlcad/branches/brep-debug/doc/docbook/system/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/system/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/system/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -4,6 +4,11 @@
${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-man-xhtml-stylesheet.xsl)
endif(BRLCAD_EXTRADOCS_HTML)
+if(BRLCAD_EXTRADOCS_PHP)
+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../resources/brlcad/brlcad-man-xhtml-stylesheet.xsl.in
+
${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-man-xhtml-stylesheet.xsl)
+endif(BRLCAD_EXTRADOCS_PHP)
+
# Style sheet for XSLT transformation to manual pages
if(BRLCAD_EXTRADOCS_MAN)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../resources/brlcad/brlcad-man-stylesheet.xsl.in
@@ -22,6 +27,7 @@
# customize FO stylesheets we can have separate CMake logic in
# appropriate directories to handle the customization (e.g., the
# BRL-CAD manuals in books/en/CMakeLists.txt).
+set(XSL_PHP_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/wordpress.xsl")
set(XSL_XHTML_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-man-xhtml-stylesheet.xsl")
set(XSL_MAN_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-man-stylesheet.xsl")
set(XSL_FO_STYLESHEET
"${CMAKE_CURRENT_BINARY_DIR}/../resources/brlcad/brlcad-man-fo-stylesheet.xsl")
Modified: brlcad/branches/brep-debug/doc/docbook/system/man1/en/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/system/man1/en/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/system/man1/en/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -246,6 +246,7 @@
set_source_files_properties(chan_mult.xml PROPERTIES EXTRA_MAN_OUTPUTS
"chan_add.1")
DOCBOOK_TO_HTML(man1 docbook_man1_EN html/man1/en "")
+DOCBOOK_TO_PHP(man1 docbook_man1_EN html/man1/en "")
DOCBOOK_TO_MAN(man1 docbook_man1_EN 1 1 man1 "")
if(BRLCAD_EXTRADOCS_PDF_MAN)
Modified: brlcad/branches/brep-debug/doc/docbook/system/man1/en/bwmod.xml
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/system/man1/en/bwmod.xml
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/system/man1/en/bwmod.xml
2015-06-10 17:26:54 UTC (rev 65245)
@@ -18,7 +18,13 @@
<cmdsynopsis>
<command>bwmod</command>
<arg choice='opt'>-c </arg>
- <arg choice='opt' rep='repeat'><arg choice='plain'>-a
<replaceable>add</replaceable></arg><arg choice='plain'>-s
<replaceable>sub</replaceable></arg><arg choice='plain'>-m
<replaceable>mult</replaceable></arg><arg choice='plain'>-d
<replaceable>div</replaceable></arg><arg choice='plain'>-A </arg><arg
choice='plain'>-e <replaceable>exp</replaceable></arg><arg choice='plain'>-r
<replaceable>root</replaceable></arg></arg>
+ <arg choice='opt'><arg choice='plain'>-a
<replaceable>add</replaceable></arg><arg choice='plain'>-s
<replaceable>sub</replaceable></arg>
+ <arg choice='plain'>-m <replaceable>mult</replaceable></arg><arg
choice='plain'>-d <replaceable>div</replaceable></arg><arg choice='plain'>-A
</arg>
+ <arg choice='plain'>-e <replaceable>exp</replaceable></arg><arg
choice='plain'>-r <replaceable>root</replaceable></arg>
+ <arg choice='plain'>-S <replaceable>shift</replaceable></arg><arg
choice='plain'>-M <replaceable>and</replaceable></arg>
+ <arg choice='plain'>-O <replaceable>or</replaceable></arg><arg
choice='plain'>-X <replaceable>xor</replaceable></arg>
+ <arg choice='plain'>-R</arg><arg choice='plain'>-t</arg>
+ </arg>
<arg choice='plain'><replaceable>file.bw</replaceable></arg>
<arg choice='plain'>></arg>
<arg choice='plain'><replaceable>file2.bw</replaceable></arg>
@@ -35,10 +41,10 @@
The pixel values range from 0 to 255 and are internally operated on
in floating point form (unless the
<option>-c</option>
-option has been specified) so that dynamic range, truncation, and sign,
+option has been specified) so that dynamic range, truncation, and sign
are not a problem. On output they are converted back to 8-bit unsigned
-values clipping to 0 and 255 if necessary. The number of pixels clipped
-high and low, if any, are reported to standard error on completion.</para>
+values, with clipping to 0 and 255 for values less than 0 and greater than
255. If any pixels are clipped,
+the numbers of pixels clipped, low and high, are reported to standard error on
completion.</para>
<para>If the
<option>-c</option>
@@ -64,16 +70,41 @@
to divide by a value.
<!-- .br -->
<option>-A</option>
-to take to absolute value of each pixel.
+to take absolute value.
<!-- .br -->
<option>-e </option><replaceable>val</replaceable>
-to exponentiate, i.e. raise each pixel to the power
+to exponentiate, i.e. raise to the power
<emphasis remap='I'>val</emphasis>.
<!-- .br -->
<option>-r </option><replaceable>val</replaceable>
to take the
-<emphasis remap='I'>val</emphasis>
-root of each pixel.</para>
+<emphasis remap='I'>val</emphasis>th
+root.
+<!-- .br -->
+<option>-S </option><replaceable>val</replaceable>
+to shift by <emphasis remap='I'>val</emphasis> bits. If
+<emphasis remap='I'>val</emphasis> is positive, this uses C-language
"^<<" operator, doing left-shift; if
+<emphasis remap='I'>val</emphasis> is negative, this uses C-language
">>" operator, doing right-shift by
+-<emphasis remap='I'>val</emphasis> bits. This is a bitwise operation,
+and if it is about to be used, both the pixel value and
<replaceable>val</replaceable>
+are truncated to integer. Unless <option>-c</option> is in effect,
+the resulting new value will again be placed in floating-point. (So it's
"user beware" if this option is applied to a
+non-integer value.)
+<!-- .br -->
+<option>-M </option><replaceable>val</replaceable>
+to do "and" operation with <emphasis remap='I'>val</emphasis>. See
<option>-S</option> for "user beware" about bitwise operation.
+<!-- .br -->
+<option>-O </option><replaceable>val</replaceable>
+to do (inclusive) "or" operation with <emphasis remap='I'>val</emphasis>. See
<option>-S</option> for "user beware" about bitwise operation.
+<!-- .br -->
+<option>-X </option><replaceable>val</replaceable>
+to do "exclusive or" operation with <emphasis remap='I'>val</emphasis>. See
<option>-S</option> for "user beware" about bitwise operation.
+<!-- .br -->
+<option>-R </option> to do rounding to the nearest integer.
+<!-- .br -->
+<option>-t </option> to do truncation to integer; notice the automatic use of
truncation for the bitwise options
+(<option>-S</option>, <option>-M</option>, <option>-O</option>, and
<option>-X</option>).
+</para>
<para>All arguments can be floating point values. Note that this command
can be applied to color
@@ -86,29 +117,43 @@
<para>The command
<!-- .br -->
<userinput>bwmod -m-1 -a255 < file.bw > file2.bw</userinput>
-<!-- .br -->
+</para>
+<para>
will produce the negative of a file by first multiplying by minus
-one, and then adding 255 to shift the pixels back into the 0->255
range.</para>
+one, and then adding 255 to shift the pixels back into the 0->255 range.
+(I.e., replace each pixel value by 255 minus that value.)</para>
<para>One can apply a gamma factor to a file as follows:
<!-- .br -->
<userinput>bwmod -d255 -r2.2 -m255 < file.bw > file2.bw</userinput>
-<!-- .br -->
-which will first normalize the pixel values, then take the 2.2 root
-of each pixel, and finally scale it back to 0->255.
+</para>
+<para>
+which will first normalize the pixel values (i.e., put them into 0->1,
+noting the internal use of floating point), then take the 2.2 root
+of each value, and finally scale the pixel values back to 0->255.
[Note however that applying gammas this way is not recommended since
a function call per pixel results!]</para>
-<para>Suppose you ran bwstat on a file and found min=80, max=210, mean=100.
+<para>Suppose you ran <command>bwstat</command> on a file and found min=80,
max=210, mean=100.
If you wish to expand the range of intensities, while still preserving
the mean, this can be done by:
+<!-- .br -->
<userinput>bwmod -s100 -m1.409 -a100 < file.bw > file2.bw</userinput>
+</para>
+<para>
+where 1.409 results from (255.0-100.0)/(210.0-100.0), which is what one would
use
+to boost the max value (210) to full scale (255) after subtracting the
+mean (100). Subtracting and adding 100 makes the multiply occur
+"about that point"; i.e., values less than 100 get smaller, and those
+above get higher. A <replaceable>file.bw</replaceable> for this example can
be created with these three command lines:</para>
+<para>
<!-- .br -->
-Where 1.409 results from (255-100)/(210-100) which is what one would use
-by boost the max value (210) to full scale (255) after subtracting the
-mean (100). Subtracting and adding 100 make the multiply occur
-"about that point", i.e. value less than 100 will get smaller; those
-above, higher.</para>
+<userinput>gencolor -r 11 80 >file.bw</userinput>
+<!-- .br -->
+<userinput>gencolor -r 262131 100 >>file.bw</userinput>
+<!-- .br -->
+<userinput>gencolor -r 2 210 >>file.bw</userinput>
+</para>
</refsect1>
<refsect1 xml:id='see_also'><title>SEE ALSO</title>
Modified: brlcad/branches/brep-debug/doc/docbook/system/man1/en/bwstat.xml
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/system/man1/en/bwstat.xml
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/system/man1/en/bwstat.xml
2015-06-10 17:26:54 UTC (rev 65245)
@@ -33,8 +33,8 @@
<!-- .br -->
These include:
<!-- .br -->
-The number of pixels (and the square root of this which is the
-file dimensions if square);
+The number of pixels (and the square root of this, yielding the
+file dimension if it's square);
<!-- .br -->
the max and min values;
<!-- .br -->
Modified: brlcad/branches/brep-debug/doc/docbook/system/man3/en/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/system/man3/en/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/system/man3/en/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -15,6 +15,7 @@
#set_source_files_properties(bu_htond.xml PROPERTIES EXTRA_MAN_OUTPUTS
"bu_ntohd.3")
DOCBOOK_TO_HTML(man3 docbook_man3_EN html/man3/en "")
+DOCBOOK_TO_PHP(man3 docbook_man3_EN html/man3/en "")
DOCBOOK_TO_MAN(man3 docbook_man3_EN 3 3 man3 "")
if(BRLCAD_EXTRADOCS_PDF_MAN)
Modified: brlcad/branches/brep-debug/doc/docbook/system/man5/en/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/system/man5/en/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/system/man5/en/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -31,6 +31,7 @@
DOCBOOK_TO_HTML(man5 docbook_man5_EN html/man5/en "${attributes_DEPS}")
+DOCBOOK_TO_PHP(man5 docbook_man5_EN html/man5/en "${attributes_DEPS}")
DOCBOOK_TO_MAN(man5 docbook_man5_EN 5 5 man5 "${attributes_DEPS}")
if(BRLCAD_EXTRADOCS_PDF_MAN)
Modified: brlcad/branches/brep-debug/doc/docbook/system/mann/en/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/doc/docbook/system/mann/en/CMakeLists.txt
2015-06-10 17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/doc/docbook/system/mann/en/CMakeLists.txt
2015-06-10 17:26:54 UTC (rev 65245)
@@ -259,7 +259,9 @@
set_source_files_properties(gr.xml PROPERTIES EXTRA_MAN_OUTPUTS "dg.nged")
DOCBOOK_TO_HTML(mann docbook_mann_EN html/mann/en "")
+DOCBOOK_TO_PHP(mann docbook_mann_EN html/mann/en "")
DOCBOOK_TO_HTML(mann docbook_mann_INTRO html/mann/en "")
+DOCBOOK_TO_PHP(mann docbook_mann_INTRO html/mann/en "")
DOCBOOK_TO_MAN(mann docbook_mann_EN n nged mann "")
if(BRLCAD_EXTRADOCS_PDF_MAN)
Modified: brlcad/branches/brep-debug/include/analyze.h
===================================================================
--- brlcad/branches/brep-debug/include/analyze.h 2015-06-10 17:01:40 UTC
(rev 65244)
+++ brlcad/branches/brep-debug/include/analyze.h 2015-06-10 17:26:54 UTC
(rev 65245)
@@ -132,24 +132,22 @@
struct bu_ptbl *both;
};
-
struct diff_seg {
point_t in_pt;
point_t out_pt;
};
-void
-analyze_raydiff_results_free(struct analyze_raydiff_results *results);
-
ANALYZE_EXPORT int
analyze_raydiff(struct analyze_raydiff_results **results, struct db_i *dbip,
const char *left, const char *right, struct bn_tol *tol);
+ANALYZE_EXPORT void
+analyze_raydiff_results_free(struct analyze_raydiff_results *results);
+
ANALYZE_EXPORT int
analyze_obj_inside(struct db_i *dbip, const char *outside, const char *inside,
fastf_t tol);
-
__END_DECLS
#endif /* ANALYZE_H */
Modified: brlcad/branches/brep-debug/include/bu/color.h
===================================================================
--- brlcad/branches/brep-debug/include/bu/color.h 2015-06-10 17:01:40 UTC
(rev 65244)
+++ brlcad/branches/brep-debug/include/bu/color.h 2015-06-10 17:26:54 UTC
(rev 65245)
@@ -136,13 +136,13 @@
BU_EXPORT extern int bu_str_to_rgb(char *str, unsigned char *rgb);
BU_EXPORT extern int bu_color_from_rgb_floats(struct bu_color *cp, fastf_t
*rgb);
BU_EXPORT extern int bu_color_to_rgb_floats(struct bu_color *cp, fastf_t *rgb);
+BU_EXPORT extern int bu_color_from_rgb_chars(struct bu_color *cp, unsigned
char *rgb);
+BU_EXPORT extern int bu_color_to_rgb_chars(struct bu_color *cp, unsigned char
*rgb);
/* UNIMPLEMENTED
*
- * BU_EXPORT export void bu_color_from_rgb_chars(struct bu_color *cp, unsigned
char *rgb);
- * BU_EXPORT export int bu_color_to_rgb_chars(struct bu_color *cp, unsigned
char *rgb);
- * BU_EXPORT export int bu_color_from_hsv_floats(struct bu_color *cp, fastf_t
*hsv);
- * BU_EXPORT export int bu_color_to_hsv_floats(struct bu_color *cp, fastf_t
*hsv);
+ * BU_EXPORT extern int bu_color_from_hsv_floats(struct bu_color *cp, fastf_t
*hsv);
+ * BU_EXPORT extern int bu_color_to_hsv_floats(struct bu_color *cp, fastf_t
*hsv);
*/
Modified: brlcad/branches/brep-debug/include/bu/opt.h
===================================================================
--- brlcad/branches/brep-debug/include/bu/opt.h 2015-06-10 17:01:40 UTC (rev
65244)
+++ brlcad/branches/brep-debug/include/bu/opt.h 2015-06-10 17:26:54 UTC (rev
65245)
@@ -36,43 +36,137 @@
/** @{ */
/** @file bu/opt.h */
-/* Make a human-readable define for using bu_opt_find to retrieve argv entries
- * that were not associated with options */
-#define BU_NON_OPTS -1
-
-/* Forward declaration for bu_opt_desc and bu_opt_arg_process_t */
-struct bu_opt_data;
-
/**
- * Convenience typedef for function callback to validate bu_opt
- * arguments
+ * Callback function signature for bu_opt_desc argument processing functions.
+ *
+ * Return values:
+ *
+ * -1 - Invalid argument encountered.
+ * 0 - No argument processed.
+ * >0 - Number of argv elements used in valid argument processing.
+ *
*/
-typedef int (*bu_opt_arg_process_t)(struct bu_vls *, struct bu_opt_data *);
+typedef int (*bu_opt_arg_process_t)(struct bu_vls *, int argc, const char
**argv, void *);
-/* typedefs to avoid confusion when working with bu_opt_data
- * and bu_opt_desc tables */
-typedef struct bu_ptbl bu_opt_dtbl_t;
-
-/** TODO - should this be a full struct to allow for easier iteration? */
-typedef struct bu_ptbl bu_opt_data_t;
-
/**
- * "Option description" structure
+ * "Option description" structure.
+ *
+ * This structure is used to define a command line option. The usage pattern
is to
+ * build up a BU_OPT_DESC_NULL terminated array of option descriptions, which
are
+ * used by bu_opt_parse to process an argv array.
+ *
+ * The set_var pointer points to a user selected variable. The type of the
variable
+ * needed is determined by the arg_process callback. If no callback is
present and
+ * the max arg count is zero, set_var is expected to be an integer that will
be set
+ * to 1 if the option is present in the argv string.
+*
+ * @code
+ * #define help_str "Print help and exit"
+ * static int ph = 0;
+ * static int i = 0;
+ * static fastf_t f = 0.0;
+ * struct bu_opt_desc opt_defs[4] = {
+ * {"h", "help", 0, 0, NULL, (void *)&ph , "", help_str},
+ * {"n", "num", 1, 1, &bu_opt_int, (void *)&i, "#", "Read int"},
+ * {"f", "fastf_t", 1, 1, &bu_opt_fastf_t, (void *)&f, "#", "Read
float"},
+ * BU_OPT_DESC_NULL
+ * };
+ * @endcode
+ *
+ * If an array initialization of an option description array is provided as in
+ * the above example , the variables specified by the user for setting must all
+ * be static (as long as C89 is used.) This should work for executable
+ * argc/argv parsing, but for libraries it is not advisable due to static
+ * variables rendering the function in question thread unsafe. For an approach
+ * usable in a library see the BU_OPT macro documentation.
+ *
*/
struct bu_opt_desc {
- int index;
+ const char *shortopt;
+ const char *longopt;
size_t arg_cnt_min;
size_t arg_cnt_max;
- const char *shortopt;
- const char *longopt;
bu_opt_arg_process_t arg_process;
- const char *shortopt_doc;
- const char *longopt_doc;
+ void *set_var;
+ const char *arg_helpstr;
const char *help_string;
};
-#define BU_OPT_DESC_NULL {-1, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL}
+/* Convenience definition for NULL bu_opt_desc struct */
+#define BU_OPT_DESC_NULL {NULL, NULL, 0, 0, NULL, NULL, NULL, NULL}
+/**
+ * Macro for assigning values to bu_opt_desc array entries. Use this style
+ * when it isn't possible to use static variables as set_var entries
+ * (such as libraries which need to be thread safe.)
+ *
+ * @code
+ * #define help_str "Print help and exit"
+ * int ph = 0;
+ * int i = 0;
+ * fastf_t f = 0.0;
+ * struct bu_opt_desc opt_defs[4];
+ * BU_OPT(opt_defs[0], "h", "help", 0, 0, NULL, (void *)&ph,
"", help_str);
+ * BU_OPT(opt_defs[1], "n", "num", 1, 1, &bu_opt_ind, (void *)&i,
"#", "Read int");
+ * BU_OPT(opt_defs[2], "f", "fastf_t", 1, 1, &bu_opt_fastf_t, (void *)&f,
"#", "Read float");
+ * BU_OPT_NULL(opt_defs[3]);
+ *
+ */
+#define BU_OPT(_desc, _so, _lo, _min, _max, _aprocess, _var, _ahelp, _help) { \
+ _desc.shortopt = _so; \
+ _desc.longopt = _lo; \
+ _desc.arg_cnt_min = _min; \
+ _desc.arg_cnt_max = _max; \
+ _desc.arg_process = _aprocess; \
+ _desc.set_var = _var; \
+ _desc.arg_helpstr = _ahelp; \
+ _desc.help_string = _help; \
+}
+
+/* Convenience macro for setting a bu_opt_desc struct to BU_OPT_DESC_NULL */
+#define BU_OPT_NULL(_desc) { \
+ _desc.shortopt = NULL; \
+ _desc.longopt = NULL; \
+ _desc.arg_cnt_min = 0; \
+ _desc.arg_cnt_max = 0; \
+ _desc.arg_process = NULL; \
+ _desc.set_var = NULL; \
+ _desc.arg_helpstr = NULL; \
+ _desc.help_string = NULL; \
+}
+
+
+/**
+ * Parse argv array using option descs.
+ *
+ * The bu_opt_desc array ds must be null terminated with BU_OPT_DESC_NULL.
+ *
+ * Return vals:
+ *
+ * -1 - fatal error in parsing. Program must decide to recover or exit.
+ * 0 - all argv options handled.
+ * >0 - some unused argv entries returned in unused array (if provided),
return int is unused argc count.
+ *
+ */
+BU_EXPORT extern int bu_opt_parse(const char ***unused, size_t sizeof_unused,
struct bu_vls *msgs, int ac, const char **argv, struct bu_opt_desc *ds);
+
+
+/* Standard option validators - if a custom option argument
+ * validation isn't needed, the functions below can be
+ * used for most valid data types. When data conversion is successful,
+ * the user_data pointer in bu_opt_data will point to the results
+ * of the string->[type] translation in order to allow a calling
+ * program to use the int/long/etc. without having to repeat the
+ * conversion.
+ */
+BU_EXPORT extern int bu_opt_bool(struct bu_vls *msg, int argc, const char
**argv, void *set_var);
+BU_EXPORT extern int bu_opt_int(struct bu_vls *msg, int argc, const char
**argv, void *set_var);
+BU_EXPORT extern int bu_opt_long(struct bu_vls *msg, int argc, const char
**argv, void *set_var);
+BU_EXPORT extern int bu_opt_fastf_t(struct bu_vls *msg, int argc, const char
**argv, void *set_var);
+BU_EXPORT extern int bu_opt_str(struct bu_vls *msg, int argc, const char
**argv, void *set_var);
+BU_EXPORT extern int bu_opt_vls(struct bu_vls *msg, int argc, const char
**argv, void *set_var);
+
+
/** Output format options for bu_opt documentation generation */
typedef enum {
BU_OPT_ASCII,
@@ -104,116 +198,7 @@
BU_EXPORT extern const char *bu_opt_describe(struct bu_opt_desc *ds, struct
bu_opt_desc_opts *settings);
-/**
- * Parsed option data container
- */
-struct bu_opt_data {
- struct bu_opt_desc *desc;
- unsigned int valid;
- const char *name;
- struct bu_ptbl *args;
- void *user_data; /* place for arg_process to stash data */
-};
-#define BU_OPT_DATA_NULL {NULL, 0, NULL, NULL, NULL}
-/**
- * Free a table of bu_opt_data results */
-BU_EXPORT extern void bu_opt_data_free(bu_opt_data_t *data);
-
-/**
- * Print a table of bu_opt_data structures. Caller
- * is responsible for freeing return string. */
-BU_EXPORT extern void bu_opt_data_print(bu_opt_data_t *data, const char
*title);
-
-/**
- * Convenience function for extracting args from a bu_opt_data container.
- * Provided as an easy way to get either the first arg:
- *
- * bu_opt_data_arg(d, 0)
- *
- * when it is known that there is only one argument while also allowing
- * for extraction of other args when multiples are present
- *
- * Returns NULL if the specified arg is not present. index starts from 0. */
-BU_EXPORT extern const char *bu_opt_data_arg(struct bu_opt_data *d, size_t
ind);
-
-/**
- * Find and return a specific option from a bu_opt_data_t of options using an
option
- * string as the lookup key. Will only return an option if its valid entry
- * is set to 1. A NULL value passed in for name retrieves the bu_opt_data
struct with the
- * unknown entries stored in its args table.
- */
-BU_EXPORT extern struct bu_opt_data *bu_opt_find(const char *name,
bu_opt_data_t *results);
-
-
-
-/**
- * Parse argv array using option descs.
- *
- * returns a bu_opt_data_t of bu_opt_data structure pointers, or NULL if the
parsing
- * failed. If a desc has an arg process, function, the valid field in
- * bu_opt_data for each option will indicate if the value in arg was
- * successfully processed by arg_process. In situations where multiple options
- * are present, the general rule is that the last one in the list wins.
- *
- * bu_opt_desc array ds must be null terminated with BU_OPT_DESC_NULL.
- *
- * Return 0 if parse successful (all options valid) and 1 otherwise.
- *
- *
- * Style to use when static definitions are possible
- *
- * enum d1_opt_ind {D1_HELP, D1_VERBOSITY};
- * struct bu_opt_desc d1[4] = {
- * {D1_HELP, 0, 0, "h", "help", NULL, help_str},
- * {D1_HELP, 0, 0, "?", "", NULL, help_str},
- * {D1_VERBOSITY, 0, 1, "v", "verbosity", &(d1_verbosity), "Set
verbosity"},
- * BU_OPT_DESC_NULL
- * };
- * bu_opt_data_t *results;
- * bu_opt_parse(&results, NULL, argc, argv, d1);
- */
-BU_EXPORT extern int bu_opt_parse(bu_opt_data_t **results, struct bu_vls
*msgs, int ac, const char **argv, struct bu_opt_desc *ds);
-/**
- * Option parse an argv array defined as a space separated string. This
- * is a convenience function that calls bu_opt_parse and also handles
- * breaking str down into a proper argv array. */
-BU_EXPORT extern int bu_opt_parse_str(bu_opt_data_t **results, struct bu_vls
*msgs, const char *str, struct bu_opt_desc *ds);
-
-/**
- * In situations where multiple options are present, the general rule is that
- * the last one in the list wins but there are situations where a program may
- * want to (say) accumulate multiple values past with multiple instances of the
- * same opt. bu_opt_compact implements the "last opt is winner"
- * rule, guaranteeing that the last instance of any given option is the only
one
- * in the results. This is a destructive operation, so a copy should be made
- * of the input table before compacting if the user desires to examine the
original
- * parsing data.
- */
-BU_EXPORT extern void bu_opt_compact(bu_opt_data_t *results);
-
-/**
- * Audit a set of results and remove any bu_opt_data entries that are not
marked
- * as valid.
- */
-BU_EXPORT extern void bu_opt_validate(bu_opt_data_t *results);
-
-
-/* Standard option validators - if a custom option argument
- * validation isn't needed, the functions below can be
- * used for most valid data types. When data conversion is successful,
- * the user_data pointer in bu_opt_data will point to the results
- * of the string->[type] translation in order to allow a calling
- * program to use the int/long/etc. without having to repeat the
- * conversion.
- *
- * TODO - unimplemented */
-BU_EXPORT extern int bu_opt_arg_int(struct bu_vls *msg, struct bu_opt_data
*data);
-BU_EXPORT extern int bu_opt_arg_long(struct bu_vls *msg, struct bu_opt_data
*data);
-BU_EXPORT extern int bu_opt_arg_bool(struct bu_vls *msg, struct bu_opt_data
*data);
-BU_EXPORT extern int bu_opt_arg_double(struct bu_vls *msg, struct bu_opt_data
*data);
-
-
/** @} */
__END_DECLS
Modified: brlcad/branches/brep-debug/misc/CMake/BRLCAD_Summary.cmake
===================================================================
--- brlcad/branches/brep-debug/misc/CMake/BRLCAD_Summary.cmake 2015-06-10
17:01:40 UTC (rev 65244)
+++ brlcad/branches/brep-debug/misc/CMake/BRLCAD_Summary.cmake 2015-06-10
17:26:54 UTC (rev 65245)
@@ -427,6 +427,9 @@
if(BRLCAD_EXTRADOCS_HTML)
set(DOCBOOK_FORMATS ${DOCBOOK_FORMATS} html)
endif(BRLCAD_EXTRADOCS_HTML)
+ if(BRLCAD_EXTRADOCS_PHP)
+ set(DOCBOOK_FORMATS ${DOCBOOK_FORMATS} php)
+ endif(BRLCAD_EXTRADOCS_PHP)
if(BRLCAD_EXTRADOCS_MAN)
set(DOCBOOK_FORMATS ${DOCBOOK_FORMATS} man)
endif(BRLCAD_EXTRADOCS_MAN)
Modified: brlcad/branches/brep-debug/misc/CMake/DocBook.cmake
===================================================================
--- brlcad/branches/brep-debug/misc/CMake/DocBook.cmake 2015-06-10 17:01:40 UTC
(rev 65244)
+++ brlcad/branches/brep-debug/misc/CMake/DocBook.cmake 2015-06-10 17:26:54 UTC
(rev 65245)
@@ -228,6 +228,73 @@
CMAKEFILES(${${xml_files}})
endmacro(DOCBOOK_TO_HTML targetname_suffix srcfile outfile targetdir deps_list)
+# HTML output, the format used by BRL-CAD's graphical help systems
+macro(DOCBOOK_TO_PHP targetname_suffix xml_files targetdir deps_list)
+ set(xml_valid_stamp)
+ if(BRLCAD_EXTRADOCS_PHP)
+ foreach(filename ${${xml_files}})
+ get_filename_component(filename_root "${filename}" NAME_WE)
+ set(outfile ${bin_root}/${DOC_DIR}/${targetdir}/${filename_root}.php)
+ set(targetname ${filename_root}_${targetname_suffix}_php)
+ set(CURRENT_XSL_STYLESHEET ${XSL_PHP_STYLESHEET})
+ if (EXISTS ${filename})
+ set(full_path_filename ${filename})
+ else (EXISTS ${filename})
+ set(full_path_filename ${CMAKE_CURRENT_SOURCE_DIR}/${filename})
+ endif (EXISTS ${filename})
+
+ # If we have extra outputs, need to handle them now
+ set(EXTRAS)
+ get_property(EXTRA_OUTPUTS SOURCE ${filename} PROPERTY EXTRA_PHP_OUTPUTS)
+ foreach(extra_out ${EXTRA_OUTPUTS})
+ set(EXTRAS ${EXTRAS} ${bin_root}/${DOC_DIR}/${targetdir}/${extra_out})
+ endforeach(extra_out ${EXTRA_OUTPUTS})
+
+ if(BRLCAD_EXTRADOCS_VALIDATE)
+ DB_VALIDATE_TARGET(${targetdir} "${filename}" ${filename_root})
+ endif(BRLCAD_EXTRADOCS_VALIDATE)
+
+ # Generate the script that will be used to run the XSLT executable
+ DB_SCRIPT("${targetname}" "${DOC_DIR}/${targetdir}" "${XSLT_EXECUTABLE}")
+
+ add_custom_command(
+ OUTPUT ${outfile} ${EXTRAS}
+ COMMAND ${CMAKE_COMMAND} -P ${scriptfile}
+ DEPENDS ${full_path_filename} ${xml_valid_stamp}
${XSLTPROC_EXECUTABLE_TARGET} ${DOCBOOK_RESOURCE_FILES} ${XSL_PHP_STYLESHEET}
${deps_list}
+ )
+ add_custom_target(${targetname} ALL DEPENDS ${outfile})
+ set_target_properties(${targetname} PROPERTIES FOLDER "DocBook/HTML")
+
+ # CMAKE_CFG_INTDIR can't be used in installation rules:
+ # http://www.cmake.org/Bug/view.php?id=5747
+ if(CMAKE_CONFIGURATION_TYPES)
+ string(REPLACE "${CMAKE_CFG_INTDIR}" "\${BUILD_TYPE}" outfile
"${outfile}")
+ if(EXTRAS)
+ string(REPLACE "${CMAKE_CFG_INTDIR}" "\${BUILD_TYPE}" EXTRAS "${EXTRAS}")
+ endif(EXTRAS)
+ endif(CMAKE_CONFIGURATION_TYPES)
+ install(FILES ${outfile} ${EXTRAS} DESTINATION ${DOC_DIR}/${targetdir})
+
+ get_property(BRLCAD_EXTRADOCS_PHP_TARGETS GLOBAL PROPERTY
BRLCAD_EXTRADOCS_PHP_TARGETS)
+ set(BRLCAD_EXTRADOCS_PHP_TARGETS ${BRLCAD_EXTRADOCS_PHP_TARGETS}
${targetname})
+ set_property(GLOBAL PROPERTY BRLCAD_EXTRADOCS_PHP_TARGETS
"${BRLCAD_EXTRADOCS_PHP_TARGETS}")
+
+ # If multiple outputs are being generated from the same file, make sure
+ # one of them is run to completion before the others to avoid multiple
+ # triggerings of the XML validation command.
+ get_property(1ST_TARGET SOURCE ${filename} PROPERTY 1ST_TARGET)
+ if(1ST_TARGET)
+ add_dependencies(${targetname} ${1ST_TARGET})
+ else(1ST_TARGET)
+ set_property(SOURCE ${filename} PROPERTY 1ST_TARGET "${targetname}")
+ endif(1ST_TARGET)
+
+ endforeach(filename ${${xml_files}})
+ endif(BRLCAD_EXTRADOCS_PHP)
+
+ CMAKEFILES(${${xml_files}})
+endmacro(DOCBOOK_TO_PHP targetname_suffix srcfile outfile targetdir deps_list)
+
# This macro produces Unix-style manual or "man" pages
macro(DOCBOOK_TO_MAN targetname_suffix xml_files mannum manext targetdir
deps_list)
set(xml_valid_stamp)
Modified: brlcad/branches/brep-debug/src/conv/CMakeLists.txt
===================================================================
--- brlcad/branches/brep-debug/src/conv/CMakeLists.txt 2015-06-10 17:01:40 UTC
(rev 65244)
+++ brlcad/branches/brep-debug/src/conv/CMakeLists.txt 2015-06-10 17:26:54 UTC
(rev 65245)
@@ -12,6 +12,7 @@
add_subdirectory(3dm)
add_subdirectory(gcv)
add_subdirectory(step)
+add_subdirectory(csg)
add_subdirectory(iges)
add_subdirectory(intaval)
Modified: brlcad/branches/brep-debug/src/conv/gcv/gcv.cpp
===================================================================
--- brlcad/branches/brep-debug/src/conv/gcv/gcv.cpp 2015-06-10 17:01:40 UTC
(rev 65244)
+++ brlcad/branches/brep-debug/src/conv/gcv/gcv.cpp 2015-06-10 17:26:54 UTC
(rev 65245)
@@ -32,56 +32,78 @@
/* Emulate a FASTGEN4 format option processor */
-enum fg4_opt_enums { FG4_TOL, FG4_WARN_DEFAULT_NAMES };
-struct bu_opt_desc fg4_opt_desc[3] = {
- {FG4_TOL, 1, 1, "t", "tol", NULL, "-t tol",
"--tol tol", "Dimensional tolerance." },
- {FG4_WARN_DEFAULT_NAMES, 0, 0, "w", "warn-default-names", NULL, "-w",
"--warn-default-names", "File format of input file." },
- BU_OPT_DESC_NULL
-};
-
void fast4_arg_process(const char *args) {
- struct bu_opt_data *d;
- bu_opt_data_t *results;
- if (!args) return;
+ int i = 0;
+ char *input = NULL;
+ int argc = 0;
+ char **argv = NULL;
+ int ret_argc = 0;
+ const char **non_opts;
+ static int tol = 0.0;
+ static int w_flag;
+ struct bu_opt_desc fg4_opt_desc[3] = {
+ {"t", "tol", 1, 1, &bu_opt_int, (void *)&tol, "tol",
"Dimensional tolerance."},
+ {"w", "warn-default-names", 0, 0, NULL, (void *)&w_flag, "", "File
format of input file."},
+ BU_OPT_DESC_NULL
+ };
- (void)bu_opt_parse_str(&results, NULL, args, fg4_opt_desc);
- bu_opt_compact(results);
- bu_opt_validate(results);
- d = bu_opt_find("w", results);
- if (d) {
- bu_log("FASTGEN 4 opt found: %s\n", d->name);
+ input = bu_strdup(args);
+ argv = (char **)bu_calloc(strlen(input) + 1, sizeof(char *), "argv array");
+ argc = bu_argv_from_string(argv, strlen(input), input);
+
+ non_opts = (const char **)bu_calloc(strlen(args) + 1, sizeof(const char
*), "non_opts array");
+ ret_argc = bu_opt_parse(&non_opts, strlen(args), NULL, argc, (const char
**)argv, fg4_opt_desc);
+
+ if (w_flag) bu_log("FASTGEN 4 warn default names set\n");
+ bu_log("FASTGEN 4 tol: %d\n", tol);
+
+ if (ret_argc) {
+ bu_log("Unknown args: ");
+ for (i = 0; i < ret_argc - 1; i++) {
+ bu_log("%s, ", non_opts[i]);
+ }
+ bu_log("%s\n", non_opts[ret_argc - 1]);
}
- bu_opt_data_print(results, "FASTGEN4 option parsing results:");
-
- bu_opt_data_free(results);
+ bu_free(input, "free array");
+ bu_free(argv, "free argv");
}
-/* Emulate a STL format option processor */
-enum stl_opt_enums { STL_TOL, STL_UNITS };
-struct bu_opt_desc stl_opt_desc[3] = {
- {STL_TOL, 1, 1, "t", "tol", NULL, "-t tol", "--tol tol",
"Dimensional tolerance." },
- {STL_UNITS, 1, 1, "u", "units", NULL, "-u unit", "--units unit", "Units
of input file." },
- BU_OPT_DESC_NULL
-};
-
void stl_arg_process(const char *args) {
- struct bu_opt_data *d;
- bu_opt_data_t *results;
- if (!args) return;
+ int i= 0;
+ char *input = NULL;
+ int argc = 0;
+ char **argv = NULL;
+ int ret_argc = 0;
+ const char **non_opts;
+ static int tol = 0.0;
+ static int units = 0;
+ struct bu_opt_desc stl_opt_desc[3] = {
+ {"t", "tol", 1, 1, &bu_opt_int, (void *)&tol, "tol", "Dimensional
tolerance." },
+ {"u", "units", 1, 1, &bu_opt_int, (void *)&units, "unit", "Units of
input file." },
+ BU_OPT_DESC_NULL
+ };
- (void)bu_opt_parse_str(&results, NULL, args, stl_opt_desc);
- bu_opt_compact(results);
- bu_opt_validate(results);
- d = bu_opt_find("u", results);
- if (d) {
- bu_log("STL opt found: %s:%s\n", d->name, bu_opt_data_arg(d, 0));
- }
+ input = bu_strdup(args);
+ argv = (char **)bu_calloc(strlen(input) + 1, sizeof(char *), "argv array");
+ argc = bu_argv_from_string(argv, strlen(input), input);
- bu_opt_data_print(results, "STL option parsing results:");
+ non_opts = (const char **)bu_calloc(strlen(args) + 1, sizeof(const char
*), "non_opts array");
+ ret_argc = bu_opt_parse(&non_opts, strlen(args), NULL, argc, (const char
**)argv, stl_opt_desc);
+ bu_log("STL tol: %d\n", tol);
+ bu_log("STL units: %d\n", units);
- bu_opt_data_free(results);
+ if (ret_argc) {
+ bu_log("Unknown args: ");
+ for (i = 0; i < ret_argc - 1; i++) {
+ bu_log("%s, ", non_opts[i]);
+ }
+ bu_log("%s\n", non_opts[ret_argc - 1]);
+ }
+
+ bu_free(input, "free array");
+ bu_free(argv, "free argv");
}
HIDDEN int
@@ -221,79 +243,104 @@
}
int
-file_stat(struct bu_vls *UNUSED(msg), struct bu_opt_data *data)
+file_stat(struct bu_vls *msg, int argc, const char **argv, void *set_var)
{
- if (!data) return 0;
- if (!data->args) {
- data->valid = 0;
+ char **file_set = (char **)set_var;
+
+ if (!argv || strlen(argv[0]) || argc == 0) {
return 0;
}
- if (!bu_file_exists(bu_opt_data_arg(data, 0), NULL)){
- data->valid = 0;
+ if (!bu_file_exists(argv[0], NULL)){
+ if (msg) bu_vls_sprintf(msg, "Error - file %s does not exist!\n",
argv[0]);
+ return -1;
}
- return 0;
+
+ if (file_set) (*file_set) = bu_strdup(argv[0]);
+
+ return 1;
}
- int
-file_null(struct bu_vls *msg, struct bu_opt_data *data)
+int
+file_null(struct bu_vls *msg, int argc, const char **argv, void *set_var)
{
- if (!data) return 0;
- if (!data->args) {
- data->valid = 0;
+ char **file_set = (char **)set_var;
+
+ if (!argv || strlen(argv[0]) || argc == 0) {
return 0;
}
- if (!bu_file_exists(bu_opt_data_arg(data, 0), NULL)){
- data->valid = 0;
- if (msg) bu_vls_sprintf(msg, "Error - file %s already exists!\n",
bu_opt_data_arg(data, 0));
+ if (bu_file_exists(argv[0], NULL)){
+ if (msg) bu_vls_sprintf(msg, "Error - file %s already exists!\n",
argv[0]);
+ return -1;
}
- return 0;
+
+ if (file_set) (*file_set) = bu_strdup(argv[0]);
+
+ return 1;
}
int
-model_mime(struct bu_vls *UNUSED(msg), struct bu_opt_data *data)
+model_mime(struct bu_vls *msg, int argc, const char **argv, void *set_mime)
{
int type_int;
mime_model_t type = MIME_MODEL_UNKNOWN;
- if (!data) return 0;
- if (!data->args) {
- data->valid = 0;
+ mime_model_t *set_type = (mime_model_t *)set_mime;
+ if (!argv || argc == 0) {
return 0;
}
- type_int = bu_file_mime(bu_opt_data_arg(data, 0), MIME_MODEL);
+ type_int = bu_file_mime(argv[0], MIME_MODEL);
type = (type_int < 0) ? MIME_MODEL_UNKNOWN : (mime_model_t)type_int;
if (type == MIME_MODEL_UNKNOWN) {
- data->valid = 0;
- return 0;
+ if (msg) bu_vls_sprintf(msg, "Error - unknown geometry file type: %s
\n", argv[0]);
+ return -1;
}
- return 0;
+ if (set_type) (*set_type) = type;
+ return 1;
}
-#define gcv_help_str "Print help and exit. If a format is specified to
--help, print help specific to that format"
-enum gcv_opt_enums { GCV_HELP, IN_FILE, OUT_FILE, IN_FORMAT, OUT_FORMAT,
IN_OPTS, OUT_OPTS, GCV_OPTS_MAX };
-struct bu_opt_desc gcv_opt_desc[9] = {
- {GCV_HELP, 0, 1, "h", "help", NULL, "-h [format]",
"--help [format]", gcv_help_str},
- {GCV_HELP, 0, 1, "?", "", NULL, "-? [format]",
"", ""},
- {IN_FILE , 1, 1, "i", "input", &(file_stat), "-i file",
"--input file", "Input file." },
- {OUT_FILE, 1, 1, "o", "output", &(file_null), "-o file",
"--output file", "Output file." },
- {IN_FORMAT , 1, 1, "", "input-format", &(model_mime), "",
"--input-format format", "File format of input file." },
- {OUT_FORMAT , 1, 1, "", "output-format", &(model_mime), "",
"--output-format format", "File format of output file." },
- {IN_OPTS , 1, 1, "I", "input-only-opts", NULL, "-I
\"[opts]\"", "--input-only-opts \"[opts]\"", "Options to apply only while
processing input file. Quotes around the opts are always necessary, but
brackets are only necessary when supplying a single option without arguments
that would otherwise be interpreted as an argv entry by the shell, even with
quotes. Brackets will never hurt, and for robustness when scripting they
should always be used." },
- {OUT_OPTS, 1, 1, "O", "output-only-opts", NULL, "-O
\"[opts]\"", "--output-only-opts \"[opts]\"", "Options to apply only while
preparing output file. Quotes around the opts are always necessary, but
brackets are only necessary when supplying a single option without arguments
that would otherwise be interpreted as an argv entry by the shell, even with
quotes. Brackets will never hurt, and for robustness when scripting they
should always be used." },
- BU_OPT_DESC_NULL
+struct gcv_help_state {
+ int flag;
+ char *format;
};
+int
+gcv_help(struct bu_vls *UNUSED(msg), int argc, const char **argv, void
*set_var)
+{
+ struct gcv_help_state *gs = (struct gcv_help_state *)set_var;
+ if (gs) gs->flag = 1;
+ if (!argv || strlen(argv[0]) || argc == 0) {
+ return 0;
+ } else {
+ if (gs) gs->format = bu_strdup(argv[0]);
+ }
+ return 1;
+}
+
+#define gcv_help_str "Print help and exit. If a format is specified to
--help, print help specific to that format"
+
+#define gcv_inopt_str "Options to apply only while processing input file.
Quotes around the opts are always necessary, but brackets are only necessary
when supplying a single option without arguments that would otherwise be
interpreted as an argv entry by the shell, even with quotes. Brackets will
never hurt, and for robustness when scripting they should always be used."
+
+#define gcv_outopt_str "Options to apply only while preparing output file.
Quotes around the opts are always necessary, but brackets are only necessary
when supplying a single option without arguments that would otherwise be
interpreted as an argv entry by the shell, even with quotes. Brackets will
never hurt, and for robustness when scripting they should always be used."
+
int
main(int ac, char **av)
{
size_t i;
int fmt = 0;
int ret = 0;
+ int skip_in = 0;
+ int skip_out = 0;
const char *in_fmt = NULL;
const char *out_fmt = NULL;
- mime_model_t in_type = MIME_MODEL_UNKNOWN;
- mime_model_t out_type = MIME_MODEL_UNKNOWN;
+ static mime_model_t in_type = MIME_MODEL_UNKNOWN;
+ static mime_model_t out_type = MIME_MODEL_UNKNOWN;
+ static char *in_path_str = NULL;
+ static char *out_path_str = NULL;
+ static struct bu_vls in_only_opts = BU_VLS_INIT_ZERO;
+ static struct bu_vls out_only_opts = BU_VLS_INIT_ZERO;
+ static struct gcv_help_state hs;
+
struct bu_vls in_format = BU_VLS_INIT_ZERO;
struct bu_vls in_path_raw = BU_VLS_INIT_ZERO;
struct bu_vls in_path = BU_VLS_INIT_ZERO;
@@ -303,10 +350,25 @@
struct bu_vls log = BU_VLS_INIT_ZERO;
struct bu_vls input_opts = BU_VLS_INIT_ZERO;
struct bu_vls output_opts = BU_VLS_INIT_ZERO;
- struct bu_opt_data *d = NULL;
- struct bu_ptbl *unknown_tbl = NULL;
- bu_opt_data_t *results = NULL;
+ struct bu_vls parse_msgs = BU_VLS_INIT_ZERO;
+ int uac = 0;
+ const char **uav = (const char **)bu_calloc(ac, sizeof(char *), "unknown
results");
+ struct bu_opt_desc gcv_opt_desc[9] = {
+ {"h", "help", 0, 1, &gcv_help, (void *)&hs,
"format", gcv_help_str, },
+ {"?", "", 0, 1, &gcv_help, (void *)&hs,
"format", "", },
+ {"i", "input", 1, 1, &file_stat, (void *)&in_path_str,
"file", "Input file.", },
+ {"o", "output", 1, 1, &file_null, (void *)&out_path_str,
"file", "Output file.", },
+ {"", "input-format", 1, 1, &model_mime, (void *)&in_type,
"format", "File format of input file.", },
+ {"", "output-format", 1, 1, &model_mime, (void *)&out_type,
"format", "File format of output file." },
+ {"I", "input-only-opts", 1, 1, &bu_opt_vls, (void *)&in_only_opts,
"\"[opts]\"", gcv_inopt_str, },
+ {"O", "output-only-opts", 1, 1, &bu_opt_vls, (void *)&out_only_opts,
"\"[opts]\"", gcv_outopt_str, },
+ BU_OPT_DESC_NULL
+ };
+
+ hs.flag = 0;
+ hs.format = NULL;
+
ac-=(ac>0); av+=(ac>0); // skip program name argv[0] if present
if (ac == 0) {
@@ -317,14 +379,11 @@
goto cleanup;
}
- (void)bu_opt_parse(&results, NULL, ac, (const char **)av, gcv_opt_desc);
- bu_opt_compact(results);
+ uac = bu_opt_parse(&uav, ac, &parse_msgs, ac, (const char **)av,
gcv_opt_desc);
/* First, see if help was supplied */
- d = bu_opt_find("h", results);
- if (d) {
- const char *help_fmt = bu_opt_data_arg(d, 0);
- if (help_fmt) {
+ if (hs.flag) {
+ if (hs.format) {
// TODO - generate some help based on format
} else {
{ /* Test static help print */
@@ -361,49 +420,73 @@
/* Did we get explicit options for an input and/or output file? */
- d = bu_opt_find("i", results);
- if (d) bu_vls_sprintf(&in_path_raw, "%s", bu_opt_data_arg(d, 0));
- d = bu_opt_find("o", results);
- if (d) bu_vls_sprintf(&out_path_raw, "%s", bu_opt_data_arg(d, 0));
+ if (in_path_str) {
+ bu_vls_sprintf(&in_path_raw, "%s", in_path_str);
+ skip_in++;
+ }
+ if (out_path_str) {
+ bu_vls_sprintf(&out_path_raw, "%s", out_path_str);
+ skip_out++;
+ }
/* If not specified explicitly with -i or -o, the input and output paths
must always
* be the last two arguments supplied */
- d = bu_opt_find(NULL, results);
- if (d) {
- unknown_tbl = d->args;
- if (unknown_tbl && BU_PTBL_LEN(unknown_tbl) > 1)
- bu_vls_sprintf(&in_path_raw, "%s", (const char
*)BU_PTBL_GET(unknown_tbl, BU_PTBL_LEN(unknown_tbl) - 2));
- if (unknown_tbl && BU_PTBL_LEN(unknown_tbl) > 0)
- bu_vls_sprintf(&out_path_raw, "%s", (const char
*)BU_PTBL_GET(unknown_tbl, BU_PTBL_LEN(unknown_tbl) - 1));
+ if (uac > 0 && !(skip_in && skip_out)) {
+ if (skip_in && !skip_out) {
+ bu_vls_sprintf(&out_path_raw, "%s", uav[uac - 1]);
+ uac--;
+ }
+ if (!skip_in && skip_out) {
+ bu_vls_sprintf(&in_path_raw, "%s", uav[uac - 1]);
+ uac--;
+ }
+ if (!skip_in && !skip_out) {
+ if (uac > 1) {
+ bu_vls_sprintf(&in_path_raw, "%s", uav[uac - 2]);
+ bu_vls_sprintf(&out_path_raw, "%s", uav[uac - 1]);
+ uac = uac -2;
+ } else {
+ bu_vls_sprintf(&in_path_raw, "%s", uav[uac - 1]);
+ uac--;
+ }
+ }
}
/* Any unknown strings not otherwise processed are passed to both input
and output.
* These are deliberately placed at the beginning of the input strings, so
any
* input/output specific options have a chance to override them. */
- if (unknown_tbl && BU_PTBL_LEN(unknown_tbl) > 2) {
- for (i = 0; i < BU_PTBL_LEN(unknown_tbl) - 2; i++) {
- bu_vls_printf(&input_opts, " %s ", (const char
*)BU_PTBL_GET(unknown_tbl, i));
- bu_vls_printf(&output_opts, " %s ", (const char
*)BU_PTBL_GET(unknown_tbl, i));
+ if (uac) {
+ for (i = 0; i < (size_t)uac; i++) {
+ if (i != 0) {
+ bu_vls_printf(&input_opts, " ");
+ bu_vls_printf(&output_opts, " ");
+ }
+ bu_vls_printf(&input_opts, "%s", uav[i]);
+ bu_vls_printf(&output_opts, "%s", uav[i]);
}
if (bu_vls_strlen(&input_opts) > 0) bu_log("Unknown options (input):
%s\n", bu_vls_addr(&input_opts));
if (bu_vls_strlen(&output_opts) > 0) bu_log("Unknown options (output):
%s\n", bu_vls_addr(&output_opts));
}
/* If we have input and/or output specific options, append them now */
- d = bu_opt_find("I", results);
- if (d) {
+ if (bu_vls_strlen(&in_only_opts) > 0) {
struct bu_vls o_tmp = BU_VLS_INIT_ZERO;
- bu_vls_sprintf(&o_tmp, "%s", bu_opt_data_arg(d, 0));
+ if (bu_vls_strlen(&input_opts) > 0)
+ bu_vls_printf(&input_opts, " ");
+
+ bu_vls_sprintf(&o_tmp, "%s", bu_vls_addr(&in_only_opts));
if (bu_vls_addr(&o_tmp)[0] == '[') bu_vls_nibble(&o_tmp, 1);
if (bu_vls_addr(&o_tmp)[strlen(bu_vls_addr(&o_tmp)) - 1] == ']')
bu_vls_trunc(&o_tmp, -1);
bu_vls_printf(&input_opts, "%s", bu_vls_addr(&o_tmp));
if (bu_vls_strlen(&input_opts) > 0) bu_log("Input only opts: %s\n",
bu_vls_addr(&o_tmp));
bu_vls_free(&o_tmp);
}
- d = bu_opt_find("O", results);
- if (d) {
+ if (bu_vls_strlen(&out_only_opts) > 0) {
struct bu_vls o_tmp = BU_VLS_INIT_ZERO;
- bu_vls_sprintf(&o_tmp, "%s", bu_opt_data_arg(d, 0));
+ if (bu_vls_strlen(&output_opts) > 0)
+ bu_vls_printf(&output_opts, " ");
+
+ bu_vls_sprintf(&o_tmp, "%s", &out_only_opts);
if (bu_vls_addr(&o_tmp)[0] == '[') bu_vls_nibble(&o_tmp, 1);
if (bu_vls_addr(&o_tmp)[strlen(bu_vls_addr(&o_tmp)) - 1] == ']')
bu_vls_trunc(&o_tmp, -1);
bu_vls_printf(&output_opts, "%s", bu_vls_addr(&o_tmp));
@@ -437,29 +520,17 @@
}
/* Find out what input file type we are dealing with */
-
- /* If we have input and/or output specific options, append them now */
- d = bu_opt_find("input-format", results);
- if (d) {
- in_fmt = bu_opt_data_arg(d, 0);
- } else {
- /* If we aren't overridden by an option, it's worth doing file
- * introspection to see if the file contents identify the input
- * type solidly, provided we have that capability.*/
-
- /* fake type introspection for testing: */
- //bu_vls_sprintf(&in_format, "step");
+ if (in_type == MIME_MODEL_UNKNOWN) {
+ fmt = parse_model_string(&in_format, &log, in_fmt,
bu_vls_addr(&in_path_raw));
+ in_type = (fmt < 0) ? MIME_MODEL_UNKNOWN : (mime_model_t)fmt;
+ in_fmt = NULL;
}
- fmt = parse_model_string(&in_format, &log, in_fmt,
bu_vls_addr(&in_path_raw));
- in_type = (fmt < 0) ? MIME_MODEL_UNKNOWN : (mime_model_t)fmt;
- in_fmt = NULL;
-
/* Identify output file type */
- d = bu_opt_find("output-format", results);
- if (d) out_fmt = bu_opt_data_arg(d, 0);
- fmt = parse_model_string(&out_format, &log, out_fmt,
bu_vls_addr(&out_path_raw));
- out_type = (fmt < 0) ? MIME_MODEL_UNKNOWN : (mime_model_t)fmt;
- out_fmt = NULL;
+ if (out_type == MIME_MODEL_UNKNOWN) {
+ fmt = parse_model_string(&out_format, &log, out_fmt,
bu_vls_addr(&out_path_raw));
+ out_type = (fmt < 0) ? MIME_MODEL_UNKNOWN : (mime_model_t)fmt;
+ out_fmt = NULL;
+ }
/* If we get to this point without knowing both input and output types,
we've got a problem */
if (in_type == MIME_MODEL_UNKNOWN) {
@@ -526,8 +597,8 @@
bu_vls_free(&log);
bu_vls_free(&input_opts);
bu_vls_free(&output_opts);
- bu_opt_data_free(results);
-
+ bu_vls_free(&in_only_opts);
+ bu_vls_free(&out_only_opts);
return ret;
}
Modified: brlcad/branches/brep-debug/src/external/README
===================================================================
--- brlcad/branches/brep-debug/src/external/README 2015-06-10 17:01:40 UTC
(rev 65244)
+++ brlcad/branches/brep-debug/src/external/README 2015-06-10 17:26:54 UTC
(rev 65245)
@@ -15,11 +15,6 @@
representation (.sat). This code utilizes the CUBIT's CGM API and must be
linked against CUBIT's CGM libraries and the ACIS CAD kernel.
-EndgameFramework
- This code is a "Simulation Module" for the Endgame Framework
-that provides BRL-CAD import functionality for v4/v5 binary geometry
-database files.
-
ProEngineer
This code is a Pro/Engineer exporter plugin module intended to
be used directly within the Pro/Engineer environment (e.g. Wildfire).
Modified: brlcad/branches/brep-debug/src/libbu/booleanize.c
===================================================================
--- brlcad/branches/brep-debug/src/libbu/booleanize.c 2015-06-10 17:01:40 UTC
(rev 65244)
+++ brlcad/branches/brep-debug/src/libbu/booleanize.c 2015-06-10 17:26:54 UTC
(rev 65245)
@@ -58,6 +58,17 @@
return 0;
}
+ /* exactly "f" or "F" (for false) */
+ if (BU_STR_EQUIV(newstr, "f")) {
+ bu_vls_free(&vls);
+ return 0;
+ }
+
+ /* exact case insensitive match for "false" */
+ if (BU_STR_EQUIV(newstr, "false")) {
+ bu_vls_free(&vls);
+ return 0;
+ }
/* exactly "0" */
if (BU_STR_EQUAL(newstr, "0")) {
bu_vls_free(&vls);
@@ -85,6 +96,18 @@
return 1;
}
+ /* exactly "t" or "T" (for true) */
+ if (BU_STR_EQUIV(newstr, "t")) {
+ bu_vls_free(&vls);
+ return 1;
+ }
+
+ /* exact case insensitive match for "true" */
+ if (BU_STR_EQUIV(newstr, "true")) {
+ bu_vls_free(&vls);
+ return 1;
+ }
+
/* exactly "1" */
if (BU_STR_EQUAL(newstr, "1")) {
bu_vls_free(&vls);
Modified: brlcad/branches/brep-debug/src/libbu/color.c
===================================================================
--- brlcad/branches/brep-debug/src/libbu/color.c 2015-06-10 17:01:40 UTC
(rev 65244)
+++ brlcad/branches/brep-debug/src/libbu/color.c 2015-06-10 17:26:54 UTC
(rev 65245)
@@ -215,8 +215,47 @@
return 1;
}
+int
+bu_color_to_rgb_chars(struct bu_color *cp, unsigned char *rgb)
+{
+ unsigned int r, g, b;
+ if (UNLIKELY(!cp || !rgb)) {
+ return 0;
+ }
+ r = (unsigned int)cp->buc_rgb[RED];
+ g = (unsigned int)cp->buc_rgb[GRN];
+ b = (unsigned int)cp->buc_rgb[BLU];
+ rgb[0] = (unsigned char)r;
+ rgb[1] = (unsigned char)g;
+ rgb[2] = (unsigned char)b;
+
+ return 1;
+}
+
+
int
+bu_color_from_rgb_chars(struct bu_color *cp, unsigned char *rgb)
+{
+ unsigned int r, g, b;
+ if (UNLIKELY(!cp || !rgb)) {
+ return 0;
+ }
+
+ r = (unsigned int)rgb[RED];
+ g = (unsigned int)rgb[GRN];
+ b = (unsigned int)rgb[BLU];
+
+
+ cp->buc_rgb[RED] = (fastf_t)r;
+ cp->buc_rgb[GRN] = (fastf_t)g;
+ cp->buc_rgb[BLU] = (fastf_t)b;
+
+ return 1;
+}
+
+
+int
bu_color_to_rgb_floats(struct bu_color *cp, fastf_t *rgb)
{
if (UNLIKELY(!cp || !rgb)) {
Modified: brlcad/branches/brep-debug/src/libbu/opt.c
===================================================================
--- brlcad/branches/brep-debug/src/libbu/opt.c 2015-06-10 17:01:40 UTC (rev
65244)
+++ brlcad/branches/brep-debug/src/libbu/opt.c 2015-06-10 17:26:54 UTC (rev
65245)
@@ -22,7 +22,10 @@
#include <stdio.h>
#include <string.h>
+#include <stdlib.h> /* for strtol */
+#include <limits.h> /* for INT_MAX */
#include <ctype.h> /* for isspace */
+#include <errno.h> /* for errno */
#include "bu/log.h"
#include "bu/malloc.h"
@@ -32,134 +35,6 @@
#include "bu/vls.h"
HIDDEN void
-bu_opt_data_init_entry(struct bu_opt_data **d, const char *name)
-{
- if (!d) return;
- BU_GET(*d, struct bu_opt_data);
- (*d)->desc = NULL;
- (*d)->valid = 1;
- (*d)->name = name;
- (*d)->args = NULL;
- (*d)->user_data = NULL;
-}
-
-HIDDEN void
-bu_opt_data_free_entry(struct bu_opt_data *d)
-{
- if (!d) return;
- if (d->name) bu_free((char *)d->name, "free data name");
- if (d->user_data) bu_free(d->user_data, "free user data");
- if (d->args) {
- size_t i;
- for (i = 0; i < BU_PTBL_LEN(d->args); i++) {
- char *arg = (char *)BU_PTBL_GET(d->args, i);
- bu_free(arg, "free arg");
- }
- bu_ptbl_free(d->args);
- BU_PUT(d->args, struct bu_ptbl);
- }
-}
-
-
-void
-bu_opt_data_free(struct bu_ptbl *tbl)
-{
- size_t i;
- if (!tbl) return;
- for (i = 0; i < BU_PTBL_LEN(tbl); i++) {
- struct bu_opt_data *opt = (struct bu_opt_data *)BU_PTBL_GET(tbl, i);
- bu_opt_data_free_entry(opt);
- }
- bu_ptbl_free(tbl);
- BU_PUT(tbl, struct bu_ptbl);
-}
-
-
-
-const char *
-bu_opt_data_arg(struct bu_opt_data *d, size_t ind)
-{
- if (!d) return NULL;
- if (d->args) {
- if (ind > (BU_PTBL_LEN(d->args) - 1)) return NULL;
- return (const char *)BU_PTBL_GET(d->args, ind);
- }
- return NULL;
-}
-
-void
-bu_opt_data_print(struct bu_ptbl *data, const char *title)
-{
- size_t i = 0;
- size_t j = 0;
- int offset_1 = 3;
- struct bu_vls log = BU_VLS_INIT_ZERO;
- if (!data || BU_PTBL_LEN(data) == 0) return;
- if (title) {
- bu_vls_sprintf(&log, "%s\n", title);
- } else {
- bu_vls_sprintf(&log, "Options:\n");
- }
- for (i = 0; i < BU_PTBL_LEN(data); i++) {
- struct bu_opt_data *d = (struct bu_opt_data *)BU_PTBL_GET(data, i);
- if (d->name) {
- bu_vls_printf(&log, "%*s%s", offset_1, " ", d->name);
- if (d->valid) {
- bu_vls_printf(&log, "\t(valid)");
- } else {
- bu_vls_printf(&log, "\t(invalid)");
- }
- if (d->desc && d->desc->arg_cnt_max > 0) {
- if (d->args && BU_PTBL_LEN(d->args) > 0) {
- bu_vls_printf(&log, ": ");
- for (j = 0; j < BU_PTBL_LEN(d->args) - 1; j++) {
- bu_vls_printf(&log, "%s, ", bu_opt_data_arg(d, j));
- }
- bu_vls_printf(&log, "%s\n", bu_opt_data_arg(d,
BU_PTBL_LEN(d->args) - 1));
- } else {
- bu_vls_printf(&log, "\n");
- }
- } else {
- bu_vls_printf(&log, "\n");
- }
- } else {
- bu_vls_printf(&log, "%*s(unknown): ", offset_1, " ", d->name);
- if (d->args && BU_PTBL_LEN(d->args) > 0) {
- for (j = 0; j < BU_PTBL_LEN(d->args) - 1; j++) {
- bu_vls_printf(&log, "%s ", bu_opt_data_arg(d, j));
- }
- bu_vls_printf(&log, "%s\n", bu_opt_data_arg(d,
BU_PTBL_LEN(d->args) - 1));
- }
- }
- }
- bu_log("%s", bu_vls_addr(&log));
- bu_vls_free(&log);
-}
-
-struct bu_opt_data *
-bu_opt_find(const char *name, struct bu_ptbl *opts)
-{
- size_t i;
- if (!opts) return NULL;
-
- for (i = 0; i < BU_PTBL_LEN(opts); i++) {
- struct bu_opt_data *opt = (struct bu_opt_data *)BU_PTBL_GET(opts, i);
- /* Don't check the unknown opts - they were already marked as not
- * valid opts per the current descriptions in the parsing pass */
- if (!name && !opt->name) return opt;
- if (!opt->name) continue;
- if (!opt->desc) continue;
- if (BU_STR_EQUAL(opt->desc->shortopt, name) ||
BU_STR_EQUAL(opt->desc->longopt, name)) {
- /* option culling guarantees us one "winner" if multiple instances
- * of an option were originally supplied, so if we find a match we
- * have found what we wanted. Now, just need to check validity */
- return (opt->valid) ? opt : NULL;
- }
- }
- return NULL;
-}
-
-HIDDEN void
wrap_help(struct bu_vls *help, int indent, int offset, int len)
{
int i = 0;
@@ -192,8 +67,26 @@
bu_free(argv, "argv");
}
+HIDDEN int
+opt_desc_is_null(struct bu_opt_desc *ds)
+{
+ int non_null = 0;
+ if (!ds) return 1;
+
+ if (ds->arg_cnt_min != 0) non_null++;
+ if (ds->arg_cnt_max != 0) non_null++;
+ if (ds->shortopt) non_null++;
+ if (ds->longopt) non_null++;
+ if (ds->arg_process) non_null++;
+ if (ds->arg_helpstr) non_null++;
+ if (ds->help_string) non_null++;
+ if (ds->set_var) non_null++;
+
+ return (non_null > 0) ? 0 : 1;
+}
+
HIDDEN const char *
-bu_opt_describe_internal_ascii(struct bu_opt_desc *ds, bu_opt_dtbl_t *tbl,
struct bu_opt_desc_opts *settings)
+bu_opt_describe_internal_ascii(struct bu_opt_desc *ds, struct bu_opt_desc_opts
*settings)
{
size_t i = 0;
size_t j = 0;
@@ -208,7 +101,7 @@
const char *finalized;
struct bu_vls description = BU_VLS_INIT_ZERO;
int *status;
- if (((!ds || ds[0].index == -1) && !tbl) || (ds && tbl)) return NULL;
+ if (!ds || opt_desc_is_null(&ds[0])) return NULL;
if (settings) {
offset = settings->offset;
@@ -216,12 +109,7 @@
desc_cols = settings->description_columns;
}
- if (ds) {
- while (ds[i].index != -1) i++;
- } else {
- int tbl_len = BU_PTBL_LEN(tbl) - 1;
- i = (tbl_len < 0) ? 0 : tbl_len;
- }
+ while (!opt_desc_is_null(&ds[i])) i++;
if (i == 0) return NULL;
opt_cnt = i;
status = (int *)bu_calloc(opt_cnt, sizeof(int), "opt status");
@@ -229,36 +117,61 @@
while (i < opt_cnt) {
struct bu_opt_desc *curr;
struct bu_opt_desc *d;
- curr = (ds) ? &(ds[i]) : (struct bu_opt_desc *)BU_PTBL_GET(tbl, i) ;
+ curr = &(ds[i]);
if (!status[i]) {
struct bu_vls opts = BU_VLS_INIT_ZERO;
struct bu_vls help_str = BU_VLS_INIT_ZERO;
- /* We handle all entries with the same key in the same
+ /* We handle all entries with the same set_var in the same
* pass, so set the status flags accordingly */
j = i;
while (j < opt_cnt) {
- d = (ds) ? &(ds[j]) : (struct bu_opt_desc *)BU_PTBL_GET(tbl, j);
- if (d->index == curr->index) {
+ d = &(ds[j]);
+ if (d == curr || (d->set_var && curr->set_var && d->set_var ==
curr->set_var)) {
status[j] = 1;
}
j++;
}
/* Collect the short options first - may be multiple instances with
- * the same index defining aliases, so accumulate all of them. */
+ * the same set_var, so accumulate all of them. */
j = i;
while (j < opt_cnt) {
- d = (ds) ? &(ds[j]) : (struct bu_opt_desc *)BU_PTBL_GET(tbl, j);
- if (d->index == curr->index) {
- int new_len = strlen(d->shortopt_doc);
- if (new_len > 0) {
+ d = &(ds[j]);
+ if (d == curr || (d->set_var && curr->set_var && d->set_var ==
curr->set_var)) {
+ if (d->shortopt && strlen(d->shortopt) > 0) {
+ struct bu_vls tmp_arg = BU_VLS_INIT_ZERO;
+ int new_len = strlen(d->arg_helpstr);
+ if (d->arg_cnt_min == 0 && d->arg_cnt_max != 0) {
+ if (new_len > 0) {
+ bu_vls_sprintf(&tmp_arg, "-%s [%s]",
d->shortopt, d->arg_helpstr);
+ new_len = new_len + 5;
+ } else {
+ bu_vls_sprintf(&tmp_arg, "-%s [opts]",
d->shortopt);
+ new_len = 9;
+ }
+ } else {
+ if (d->arg_cnt_min == 0 && d->arg_cnt_max == 0) {
+ bu_vls_sprintf(&tmp_arg, "-%s", d->shortopt);
+ new_len = 2;
+ }
+ if (d->arg_cnt_min > 0) {
+ if (new_len > 0) {
+ bu_vls_sprintf(&tmp_arg, "-%s %s",
d->shortopt, d->arg_helpstr);
+ new_len = new_len + 3;
+ } else {
+ bu_vls_sprintf(&tmp_arg, "-%s opts",
d->shortopt);
+ new_len = 7;
+ }
+ }
+ }
if ((int)bu_vls_strlen(&opts) + new_len + offset + 2 >
opt_cols + desc_cols) {
bu_vls_printf(&description, "%*s%s\n", offset, " ",
bu_vls_addr(&opts));
- bu_vls_sprintf(&opts, "%s, ", d->shortopt_doc);
+ bu_vls_sprintf(&opts, "%s, ",
bu_vls_addr(&tmp_arg));
} else {
- bu_vls_printf(&opts, "%s, ", d->shortopt_doc);
+ bu_vls_printf(&opts, "%s, ", bu_vls_addr(&tmp_arg));
}
+ bu_vls_free(&tmp_arg);
}
/* While we're at it, pick up the string. The last string
with
* a matching key wins, as long as its not empty */
@@ -270,16 +183,41 @@
/* Now do the long opts */
j = i;
while (j < opt_cnt) {
- d = (ds) ? &(ds[j]) : (struct bu_opt_desc *)BU_PTBL_GET(tbl, j);
- if (d->index == curr->index) {
- int new_len = strlen(d->longopt_doc);
- if (new_len > 0) {
+ d = &(ds[j]);
+ if (d == curr || (d->set_var && curr->set_var && d->set_var ==
curr->set_var)) {
+ if (d->longopt && strlen(d->longopt) > 0) {
+ struct bu_vls tmp_arg = BU_VLS_INIT_ZERO;
+ int new_len = strlen(d->arg_helpstr);
+ if (d->arg_cnt_min == 0 && d->arg_cnt_max != 0) {
+ if (new_len > 0) {
+ bu_vls_sprintf(&tmp_arg, "--%s [%s]",
d->longopt, d->arg_helpstr);
+ new_len = new_len + strlen(d->longopt) + 5;
+ } else {
+ bu_vls_sprintf(&tmp_arg, "--%s [opts]",
d->longopt);
+ new_len = strlen(d->longopt) + 9;
+ }
+ } else {
+ if (d->arg_cnt_min == 0 && d->arg_cnt_max == 0) {
+ bu_vls_sprintf(&tmp_arg, "--%s", d->longopt);
+ new_len = strlen(d->longopt) + 2;
+ }
+ if (d->arg_cnt_min > 0) {
+ if (new_len > 0) {
+ bu_vls_sprintf(&tmp_arg, "--%s %s",
d->longopt, d->arg_helpstr);
+ new_len = strlen(d->longopt) + new_len + 3;
+ } else {
+ bu_vls_sprintf(&tmp_arg, "--%s opts",
d->longopt);
+ new_len = strlen(d->longopt) + 7;
+ }
+ }
+ }
if ((int)bu_vls_strlen(&opts) + new_len + offset + 2 >
opt_cols + desc_cols) {
bu_vls_printf(&description, "%*s%s\n", offset, " ",
bu_vls_addr(&opts));
- bu_vls_sprintf(&opts, "%s, ", d->longopt_doc);
+ bu_vls_sprintf(&opts, "%s, ",
bu_vls_addr(&tmp_arg));
} else {
- bu_vls_printf(&opts, "%s, ", d->longopt_doc);
+ bu_vls_printf(&opts, "%s, ", bu_vls_addr(&tmp_arg));
}
+ bu_vls_free(&tmp_arg);
}
}
j++;
@@ -311,30 +249,19 @@
bu_opt_describe(struct bu_opt_desc *ds, struct bu_opt_desc_opts *settings)
{
if (!ds) return NULL;
- if (!settings) return bu_opt_describe_internal_ascii(ds, NULL, NULL);
+ if (!settings) return bu_opt_describe_internal_ascii(ds, NULL);
return NULL;
}
-const char *
-bu_opt_describe_dtbl(bu_opt_dtbl_t *dtbl, struct bu_opt_desc_opts *settings)
-{
- if (!dtbl) return NULL;
- if (!settings) return bu_opt_describe_internal_ascii(NULL, dtbl, NULL);
- return NULL;
-}
-
-
HIDDEN char *
-opt_process(char **eq_arg, const char *opt_candidate)
+opt_process(const char **eq_arg, const char *opt_candidate)
{
int offset = 1;
- char *inputcpy;
char *final_opt;
char *equal_pos;
if (!eq_arg && !opt_candidate) return NULL;
- inputcpy = bu_strdup(opt_candidate);
- if (inputcpy[1] == '-') offset++;
- equal_pos = strchr(inputcpy, '=');
+ if (opt_candidate[1] == '-') offset++;
+ equal_pos = strchr(opt_candidate, '=');
/* If we've got a single opt, things are handled differently */
if (offset == 1) {
@@ -345,13 +272,12 @@
* interpretation in this context is everything after
* the first letter is arg.*/
struct bu_vls vopt = BU_VLS_INIT_ZERO;
- struct bu_vls varg = BU_VLS_INIT_ZERO;
- bu_vls_strncat(&vopt, inputcpy+1, 1);
- bu_vls_sprintf(&varg, "%s", inputcpy);
- bu_vls_nibble(&varg, 2);
+ const char *varg = opt_candidate;
+ bu_vls_strncat(&vopt, opt_candidate+1, 1);
-#if 0
- /* A possible exception is an equals sign, e.g. -s=1024 - in that
+ varg = opt_candidate + 2;
+
+ /* A exception is an equals sign, e.g. -s=1024 - in that
* instance, the expectation might be that = would be interpreted
* as an assignment. This means that to get the literal =1024 as
* an option, you would need a space after the s, e.g.: -s =1024
@@ -360,102 +286,41 @@
* "looks right" - may be worth revisiting or even an option at
* some point...*/
- if (equal_pos && equal_pos == inputcpy+2) {
- bu_vls_nibble(&varg, 1);
- }
-#endif
+ if (equal_pos) varg++;
- (*eq_arg) = bu_strdup(bu_vls_addr(&varg));
+ (*eq_arg) = varg;
final_opt = bu_strdup(bu_vls_addr(&vopt));
bu_vls_free(&vopt);
- bu_vls_free(&varg);
}
} else {
if (equal_pos) {
struct bu_vls vopt = BU_VLS_INIT_ZERO;
- struct bu_vls varg = BU_VLS_INIT_ZERO;
- bu_vls_sprintf(&vopt, "%s", inputcpy);
+ const char *varg = opt_candidate;
+ bu_vls_sprintf(&vopt, "%s", opt_candidate);
bu_vls_trunc(&vopt, -1 * strlen(equal_pos));
bu_vls_nibble(&vopt, offset);
- bu_vls_sprintf(&varg, "%s", inputcpy);
- bu_vls_nibble(&varg, strlen(inputcpy) - strlen(equal_pos) + 1);
- (*eq_arg) = bu_strdup(bu_vls_addr(&varg));
+
+ varg = opt_candidate + bu_vls_strlen(&vopt) + 2;
+ if (equal_pos) varg++;
+
+ (*eq_arg) = varg;
final_opt = bu_strdup(bu_vls_addr(&vopt));
bu_vls_free(&vopt);
- bu_vls_free(&varg);
} else {
final_opt = bu_strdup(opt_candidate+offset);
}
}
- bu_free(inputcpy, "cleanup working copy");
return final_opt;
}
-void
-bu_opt_compact(struct bu_ptbl *opts)
-{
- int i;
- int ptblpos = BU_PTBL_LEN(opts) - 1;
- struct bu_ptbl tbl;
- bu_ptbl_init(&tbl, 8, "local table");
- while (ptblpos >= 0) {
- struct bu_opt_data *data = (struct bu_opt_data *)BU_PTBL_GET(opts,
ptblpos);
- if (!data) {
- ptblpos--;
- continue;
- }
- bu_ptbl_ins(&tbl, (long *)data);
- BU_PTBL_CLEAR_I(opts, ptblpos);
- for (i = ptblpos - 1; i >= 0; i--) {
- struct bu_opt_data *dc = (struct bu_opt_data *)BU_PTBL_GET(opts, i);
- if ((dc && dc->desc && data->desc) && dc->desc->index ==
data->desc->index) {
- bu_opt_data_free_entry(dc);
- BU_PTBL_CLEAR_I(opts, i);
- }
- }
- ptblpos--;
- }
- bu_ptbl_reset(opts);
- for (i = BU_PTBL_LEN(&tbl) - 1; i >= 0; i--) {
- bu_ptbl_ins(opts, BU_PTBL_GET(&tbl, i));
- }
- bu_ptbl_free(&tbl);
-}
-
-
-void
-bu_opt_validate(struct bu_ptbl *opts)
-{
- size_t i;
- struct bu_ptbl tbl;
- bu_ptbl_init(&tbl, 8, "local table");
- for (i = 0; i < BU_PTBL_LEN(opts); i++) {
- struct bu_opt_data *dc = (struct bu_opt_data *)BU_PTBL_GET(opts, i);
- if (dc && (dc->valid || (dc->desc && dc->desc->index == -1))) {
- bu_ptbl_ins(&tbl, (long *)dc);
- } else {
- bu_opt_data_free_entry(dc);
- BU_PTBL_CLEAR_I(opts, i);
- }
- }
- bu_ptbl_reset(opts);
- for (i = 0; i < BU_PTBL_LEN(&tbl); i++) {
- bu_ptbl_ins(opts, BU_PTBL_GET(&tbl, i));
- }
- bu_ptbl_free(&tbl);
-}
-
-
-/* This implements criteria for deciding when an argv string is
+/* This implements naive criteria for deciding when an argv string is
* an option. Right now the criteria are:
*
* 1. Must have a '-' char as first character
* 2. Must not have white space characters present in the string.
- * 3. Must be an option in ds.
- * 4. Must not be a valid numerical argument to an option expecting a number.
*/
HIDDEN int
-is_opt(const char *opt, struct bu_opt_desc *UNUSED(ds)) {
+can_be_opt(const char *opt) {
size_t i = 0;
if (!opt) return 0;
if (!strlen(opt)) return 0;
@@ -466,47 +331,42 @@
return 1;
}
+
int
-bu_opt_parse(struct bu_ptbl **tbl, struct bu_vls *UNUSED(msgs), int argc,
const char **argv, struct bu_opt_desc *ds)
+bu_opt_parse(const char ***unused, size_t sizeof_unused, struct bu_vls *msgs,
int argc, const char **argv, struct bu_opt_desc *ds)
{
int i = 0;
int offset = 0;
- const char *ns = NULL;
- struct bu_ptbl *opt_data;
- struct bu_opt_data *unknowns = NULL;
- if (!argv || !ds) return 1;
+ int ret_argc = 0;
+ struct bu_ptbl unknown_args = BU_PTBL_INIT_ZERO;
+ if (!argv || !ds) return -1;
- BU_GET(opt_data, struct bu_ptbl);
- bu_ptbl_init(opt_data, 8, "opt_data");
-
/* Now identify opt/arg pairs.*/
while (i < argc) {
int desc_found = 0;
int desc_ind = 0;
size_t arg_cnt = 0;
char *opt = NULL;
- char *eq_arg = NULL;
- struct bu_opt_data *data = NULL;
+ const char *eq_arg = NULL;
struct bu_opt_desc *desc = NULL;
- /* If 'opt' isn't an option, make a container for non-option values and
build it up until
- * we reach an option */
- if (!is_opt(argv[i], ds)) {
- if (!unknowns) {
- bu_opt_data_init_entry(&unknowns, NULL);
- BU_GET(unknowns->args, struct bu_ptbl);
- bu_ptbl_init(unknowns->args, 8, "args init");
- }
- ns = bu_strdup(argv[i]);
- bu_ptbl_ins(unknowns->args, (long *)ns);
+ /* If argv[i] isn't an option, stick the argv entry (and any
+ * immediately following non-option entries) into the
+ * unknown args table */
+ if (!can_be_opt(argv[i])) {
+ bu_ptbl_ins(&unknown_args, (long *)argv[i]);
i++;
- while (i < argc && !is_opt(argv[i], ds)) {
- ns = bu_strdup(argv[i]);
- bu_ptbl_ins(unknowns->args, (long *)ns);
+ while (i < argc && !can_be_opt(argv[i])) {
+ bu_ptbl_ins(&unknown_args, (long *)argv[i]);
i++;
}
continue;
}
+ /* Now we're past the easy case, and whether something is an
+ * option or an argument depends on context. argv[i] is at least
+ * a possibility for a valid option, so the first order of business
+ * is to determine if it is one. */
+
/* It may be that an = has been used instead of a space. Handle that,
and
* strip leading '-' characters. Also, short-opt options may not have a
* space between their option and the argument. That is also handled
here */
@@ -514,7 +374,7 @@
/* Find the corresponding desc, if we have one */
desc = &(ds[0]);
- while (!desc_found && (desc && desc->index != -1)) {
+ while (!desc_found && (desc && !opt_desc_is_null(desc))) {
if (BU_STR_EQUAL(opt+offset, desc->shortopt) ||
BU_STR_EQUAL(opt+offset, desc->longopt)) {
desc_found = 1;
continue;
@@ -525,115 +385,267 @@
/* If we don't know what we're dealing with, keep going */
if (!desc_found) {
- struct bu_vls rebuilt_opt = BU_VLS_INIT_ZERO;
- if (!unknowns) {
- bu_opt_data_init_entry(&unknowns, NULL);
- BU_GET(unknowns->args, struct bu_ptbl);
- bu_ptbl_init(unknowns->args, 8, "args init");
- }
- if (strlen(opt) == 1) {
- bu_vls_sprintf(&rebuilt_opt, "-%s", opt);
- } else {
- bu_vls_sprintf(&rebuilt_opt, "--%s", opt);
- }
- bu_ptbl_ins(unknowns->args, (long
*)bu_strdup(bu_vls_addr(&rebuilt_opt)));
- bu_free(opt, "free opt");
- bu_vls_free(&rebuilt_opt);
- if (eq_arg)
- bu_ptbl_ins(unknowns->args, (long *)eq_arg);
+ /* Since the equals sign is regarded as forcing an argument
+ * to map to a particular option (and is an error if that
+ * option isn't supposed to have arguments) we pass along
+ * the original option intact. */
+ bu_ptbl_ins(&unknown_args, (long *)argv[i]);
i++;
continue;
}
- /* Initialize with opt */
- bu_opt_data_init_entry(&data, opt);
- data->desc = desc;
- if (eq_arg) {
- /* Okay, we actually need it - initialize the arg table */
- BU_GET(data->args, struct bu_ptbl);
- bu_ptbl_init(data->args, 8, "args init");
- bu_ptbl_ins(data->args, (long *)eq_arg);
- arg_cnt = 1;
- }
+ /* We've got a description of the option. Now the real work begins. */
+ if (eq_arg) arg_cnt = 1;
/* handled the option - any remaining processing is on args, if any*/
i = i + 1;
/* If we already got an arg from the equals mechanism and we aren't
- * supposed to have one, we're invalid */
- if (arg_cnt > 0 && desc->arg_cnt_max == 0) data->valid = 0;
+ * supposed to have one, we're invalid - halt. */
+ if (eq_arg && desc->arg_cnt_max == 0) {
+ if (msgs) bu_vls_printf(msgs, "Option %s takes no arguments, but
argument %s is present - halting.\n", argv[i-1], eq_arg);
+ return -1;
+ }
/* If we're looking for args, do so */
if (desc->arg_cnt_max > 0) {
- while (arg_cnt < desc->arg_cnt_max && i < argc && !is_opt(argv[i],
ds)) {
- ns = bu_strdup(argv[i]);
- if (!data->args) {
- /* Okay, we actually need it - initialize the arg table */
- BU_GET(data->args, struct bu_ptbl);
- bu_ptbl_init(data->args, 8, "args init");
+ /* If we might have args and we have a validator function,
+ * construct the greediest possible interpretation of the option
+ * description and run the validator to determine the number of
+ * argv entries associated with this option (can_be_opt is not
+ * enough if the option is number based, since -9 may be both a
+ * valid option and a valid argument - the validator must make the
+ * decision. If we do not have a validator, the best we can do
+ * is the can_be_opt test as a terminating trigger. */
+ if (desc->arg_process) {
+ /* Construct the greedy interpretation of the option argv */
+ int k = 0;
+ int arg_offset = 0;
+ int g_argc = desc->arg_cnt_max;
+ const char **g_argv = (const char **)bu_calloc(g_argc + arg_cnt
+ 1, sizeof(char *), "greedy argv");
+ if (!g_argc && arg_cnt) g_argc = arg_cnt;
+ if (i != argc || arg_cnt) {
+ if (arg_cnt)
+ g_argv[0] = eq_arg;
+ for (k = 0; k < g_argc; k++) {
+ g_argv[k+arg_cnt] = argv[i + k];
+ }
+ arg_offset = (*desc->arg_process)(msgs, g_argc, g_argv,
desc->set_var);
+ if (arg_offset == -1) {
+ /* This isn't just an unknown option to be passed
+ * through for possible later processing. If the
+ * arg_process callback returns -1, something has gone
+ * seriously awry and a known-to-be-invalid arg was
+ * seen. Fail early and hard. */
+ if (msgs) bu_vls_printf(msgs, "Invalid argument
supplied to %s: %s - halting.\n", argv[i-1], argv[i]);
+ return -1;
+ }
+ if (arg_offset == 0) {
+ if (desc->arg_cnt_min > 0) {
+ if (msgs) bu_vls_printf(msgs, "Option %s requires
an argument but none was found - halting.\n", argv[i-1]);
+ return -1;
+ } else {
+ continue;
+ }
+ }
+ i = i + arg_offset - arg_cnt;
+ } else {
+ if (desc->arg_cnt_min == 0) {
+ /* If this is allowed to function just as a flag, an
int may
+ * be supplied to record the status - try to set it */
+ int *flag_var = (int *)desc->set_var;
+ if (flag_var) (*flag_var) = 1;
+ }
}
- bu_ptbl_ins(data->args, (long *)ns);
- i++;
- arg_cnt++;
+ bu_free(g_argv, "free greedy argv");
+ } else {
+ while (arg_cnt < desc->arg_cnt_max && i < argc &&
!can_be_opt(argv[i])) {
+ i++;
+ arg_cnt++;
+ }
+ if (arg_cnt < desc->arg_cnt_min) {
+ if (msgs) bu_vls_printf(msgs, "Option %s requires at least
%d arguments but only %d were found - halting.\n", argv[i-1],
desc->arg_cnt_min, arg_cnt);
+ return -1;
+ }
}
- if (arg_cnt < desc->arg_cnt_min) {
- data->valid = 0;
- }
+ } else {
+ /* only a flag - see if we're supposed to set an int */
+ int *flag_var = (int *)desc->set_var;
+ if (flag_var) (*flag_var) = 1;
}
+ }
- /* Now see if we need to validate the arg(s) */
- if (desc->arg_process) {
- int arg_offset = (*desc->arg_process)(NULL, data);
- if (arg_offset < 0) {
- /* arg(s) present but not associated with opt, back them out of
data
- *
- * test example for this - color option
- *
- * --color 200/30/10 input output (1 arg to color, 3 args
total)
- * --color 200 30 10 input output (3 args to color, 5 total)
- *
- * to handle the color case, need to process all three in
first case,
- * recognize that first one is sufficient, and release the
latter two.
- * for the second case all three are necessary
- *
- * */
- int len = BU_PTBL_LEN(data->args);
- int j = 0;
- i = i + arg_offset;
- while (j > arg_offset) {
- bu_free((void *)BU_PTBL_GET(data->args, len + j - 1), "free
str");
- j--;
- }
- bu_ptbl_trunc(data->args, len + arg_offset);
- }
+ /* Copy as many of the unknown args as we can fit into the provided argv
array.
+ * Program must check return value to see if any were lost due to the
provided
+ * array being too small. */
+ ret_argc = BU_PTBL_LEN(&unknown_args);
+ if (ret_argc > 0 && sizeof_unused > 0 && unused) {
+ int avc = 0;
+ int max_avc_cnt = (BU_PTBL_LEN(&unknown_args) < sizeof_unused) ?
BU_PTBL_LEN(&unknown_args) : sizeof_unused;
+ for (avc = 0; avc < max_avc_cnt; avc++) {
+ (*unused)[avc] = (const char *)BU_PTBL_GET(&unknown_args, avc);
}
- bu_ptbl_ins(opt_data, (long *)data);
}
- if (unknowns) bu_ptbl_ins(opt_data, (long *)unknowns);
+ bu_ptbl_free(&unknown_args);
- (*tbl) = opt_data;
- return 0;
+ return ret_argc;
}
int
-bu_opt_parse_str(struct bu_ptbl **tbl, struct bu_vls *msgs, const char *str,
struct bu_opt_desc *ds)
+bu_opt_int(struct bu_vls *msg, int argc, const char **argv, void *set_var)
{
- int ret = 0;
- char *input = NULL;
- char **argv = NULL;
- int argc = 0;
- if (!tbl || !str || !ds) return 1;
- input = bu_strdup(str);
- argv = (char **)bu_calloc(strlen(input) + 1, sizeof(char *), "argv array");
- argc = bu_argv_from_string(argv, strlen(input), input);
+ long int l;
+ int i;
+ char *endptr = NULL;
+ int *int_set = (int *)set_var;
- ret = bu_opt_parse(tbl, msgs, argc, (const char **)argv, ds);
+ if (!argv || !argv[0] || strlen(argv[0]) == 0 || argc != 1 ) {
+ return 0;
+ }
- bu_free(input, "free str copy");
- bu_free(argv, "free argv memory");
- return ret;
+ l = strtol(argv[0], &endptr, 0);
+
+ if (endptr != NULL && strlen(endptr) > 0) {
+ /* Had some invalid character in the input, fail */
+ if (msg) bu_vls_printf(msg, "Invalid string specifier for int: %s\n",
argv[0]);
+ return -1;
+ }
+
+ if (errno == ERANGE) {
+ if (msg) bu_vls_printf(msg, "Invalid input for int (range error):
%s\n", argv[0]);
+ return -1;
+ }
+
+ /* If the long fits inside an int, we're OK */
+ if (l <= INT_MAX || l >= -INT_MAX) {
+ i = (int)l;
+ } else {
+ /* Too big or too small, fail */
+ if (msg) bu_vls_printf(msg, "String specifies number too large for int
data type: %l\n", l);
+ return -1;
+ }
+
+ if (int_set) (*int_set) = i;
+ return 1;
}
+int
+bu_opt_long(struct bu_vls *msg, int argc, const char **argv, void *set_var)
+{
+ long int l;
+ char *endptr = NULL;
+ long *long_set = (long *)set_var;
+
+ if (!argv || !argv[0] || strlen(argv[0]) == 0 || argc != 1 ) {
+ return 0;
+ }
+
+ l = strtol(argv[0], &endptr, 0);
+
+ if (endptr != NULL && strlen(endptr) > 0) {
+ /* Had some invalid character in the input, fail */
+ if (msg) bu_vls_printf(msg, "Invalid string specifier for int: %s\n",
argv[0]);
+ return -1;
+ }
+
+ if (errno == ERANGE) {
+ if (msg) bu_vls_printf(msg, "Invalid input for int (range error):
%s\n", argv[0]);
+ return -1;
+ }
+
+ if (long_set) (*long_set) = l;
+ return 1;
+}
+
+int
+bu_opt_fastf_t(struct bu_vls *msg, int argc, const char **argv, void *set_var)
+{
+ fastf_t f;
+ fastf_t *f_set = (fastf_t *)set_var;
+ char *endptr = NULL;
+
+ if (!argv || !argv[0] || strlen(argv[0]) == 0 || argc != 1 ) {
+ return 0;
+ }
+
+ if (sizeof(fastf_t) == sizeof(float)) {
+ f = strtof(argv[0], &endptr);
+ }
+
+ if (sizeof(fastf_t) == sizeof(double)) {
+ f = strtod(argv[0], &endptr);
+ }
+
+ if (endptr != NULL && strlen(endptr) > 0) {
+ /* Had some invalid character in the input, fail */
+ if (msg) bu_vls_printf(msg, "Invalid string specifier for fastf_t:
%s\n", argv[0]);
+ return -1;
+ }
+
+ if (errno == ERANGE) {
+ if (msg) bu_vls_printf(msg, "Invalid input for fastf_t (range error):
%s\n", argv[0]);
+ return -1;
+ }
+
+ if (f_set) (*f_set) = f;
+ return 1;
+}
+
+int
+bu_opt_str(struct bu_vls *UNUSED(msg), int argc, const char **argv, void
*set_var)
+{
+ const char **s_set = (const char **)set_var;
+
+ if (!argv || !argv[0] || strlen(argv[0]) == 0 || argc != 1 ) return 0;
+
+ if (s_set) (*s_set) = argv[0];
+ return 1;
+}
+
+int
+bu_opt_vls(struct bu_vls *UNUSED(msg), int argc, const char **argv, void
*set_var)
+{
+ struct bu_vls *s_set = (struct bu_vls *)set_var;
+
+ if (!argv || !argc ) return 0;
+
+ if (s_set) {
+ int i = 0;
+ for (i = 0; i < argc - 1; i++) {
+ bu_vls_printf(s_set, "%s ", argv[i]);
+ }
+ bu_vls_printf(s_set, "%s", argv[argc - 1]);
+ }
+ return 1;
+}
+
+int
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits