Revision: 76046
http://sourceforge.net/p/brlcad/code/76046
Author: starseeker
Date: 2020-06-06 18:53:11 +0000 (Sat, 06 Jun 2020)
Log Message:
-----------
Remove deprecated API from bu/cmd.h - avoids the compile-time API issue that
was keeping the user regression program from building.
Modified Paths:
--------------
brlcad/trunk/include/bu/cmd.h
brlcad/trunk/regress/user/CMakeLists.txt
brlcad/trunk/src/bwish/cmd.c
brlcad/trunk/src/libbu/CMakeLists.txt
Removed Paths:
-------------
brlcad/trunk/src/libbu/cmdhist.c
Modified: brlcad/trunk/include/bu/cmd.h
===================================================================
--- brlcad/trunk/include/bu/cmd.h 2020-06-06 18:45:23 UTC (rev 76045)
+++ brlcad/trunk/include/bu/cmd.h 2020-06-06 18:53:11 UTC (rev 76046)
@@ -30,9 +30,6 @@
#include "common.h"
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
#include <time.h>
#include "bsocket.h" /* for timeval */
@@ -52,28 +49,6 @@
int (*ct_func)(void *data, int argc, const char *argv[]);
};
-/* deprecated 2016-01-14 */
-struct bu_cmdhist {
- struct bu_vls h_command;
- struct timeval h_start;
- struct timeval h_finish;
- int h_status;
-};
-#define BU_CMDHIST_NULL (struct bu_cmdhist *)NULL
-
-struct bu_cmdhist_list {
- size_t size, capacity;
- size_t current;
- struct bu_cmdhist *cmdhist;
-};
-
-/* deprecated 2016-01-14 */
-struct bu_cmdhist_obj {
- struct bu_vls cho_name;
- struct bu_cmdhist_list cmdhist;
-};
-#define BU_CMDHIST_OBJ_NULL (struct bu_cmdhist_obj *)NULL
-
__BEGIN_DECLS
/** @brief Routine(s) for processing subcommands */
Modified: brlcad/trunk/regress/user/CMakeLists.txt
===================================================================
--- brlcad/trunk/regress/user/CMakeLists.txt 2020-06-06 18:45:23 UTC (rev
76045)
+++ brlcad/trunk/regress/user/CMakeLists.txt 2020-06-06 18:53:11 UTC (rev
76046)
@@ -15,7 +15,6 @@
# this code as well, so long as they don't also contain anything that ties this
# code to any internal, compile time behaviors or features.
-if(0)
# We deliberately do not use any of the BRL-CAD wrapper macros, to avoid
automatic
# addtiion of compile defintions or other magic specific to BRL-CAD's internal
build.
add_executable(cad_user cad_user.c)
@@ -23,10 +22,9 @@
target_include_directories(cad_user PUBLIC
"${CMAKE_BINARY_DIR}/${INCLUDE_DIR}/brlcad")
set_target_properties(cad_user PROPERTIES FOLDER "BRL-CAD Regression
Tests/user")
-endif(0)
set(LOG_FILE "${CMAKE_CURRENT_BINARY_DIR}/regress-user.log")
-#BRLCAD_REGRESSION_TEST(regress-user "cad_user;moss.g" EXEC cad_user)
+BRLCAD_REGRESSION_TEST(regress-user "cad_user;moss.g" EXEC cad_user)
DISTCLEAN(${LOG_FILE})
CMAKEFILES(
Modified: brlcad/trunk/src/bwish/cmd.c
===================================================================
--- brlcad/trunk/src/bwish/cmd.c 2020-06-06 18:45:23 UTC (rev 76045)
+++ brlcad/trunk/src/bwish/cmd.c 2020-06-06 18:53:11 UTC (rev 76046)
@@ -33,6 +33,10 @@
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+
#ifdef BWISH
# include "tk.h"
#else
@@ -44,6 +48,26 @@
#include "bu/str.h"
#include "libtermio.h"
+struct bu_cmdhist {
+ struct bu_vls h_command;
+ struct timeval h_start;
+ struct timeval h_finish;
+ int h_status;
+};
+#define BU_CMDHIST_NULL (struct bu_cmdhist *)NULL
+
+struct bu_cmdhist_list {
+ size_t size, capacity;
+ size_t current;
+ struct bu_cmdhist *cmdhist;
+};
+
+struct bu_cmdhist_obj {
+ struct bu_vls cho_name;
+ struct bu_cmdhist_list cmdhist;
+};
+#define BU_CMDHIST_OBJ_NULL (struct bu_cmdhist_obj *)NULL
+
#define BU_CMDHIST_LIST_INIT_CAPACITY 8
/* defined in tcl.c */
Modified: brlcad/trunk/src/libbu/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/libbu/CMakeLists.txt 2020-06-06 18:45:23 UTC (rev
76045)
+++ brlcad/trunk/src/libbu/CMakeLists.txt 2020-06-06 18:53:11 UTC (rev
76046)
@@ -56,7 +56,6 @@
brlcad_path.c
bu_init.cpp
cmd.c
- cmdhist.c
color.cpp
convert.c
crashreport.c
Deleted: brlcad/trunk/src/libbu/cmdhist.c
===================================================================
--- brlcad/trunk/src/libbu/cmdhist.c 2020-06-06 18:45:23 UTC (rev 76045)
+++ brlcad/trunk/src/libbu/cmdhist.c 2020-06-06 18:53:11 UTC (rev 76046)
@@ -1,260 +0,0 @@
-/* C M D H I S T . C
- * BRL-CAD
- *
- * Copyright (c) 1998-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- */
-
-#include "common.h"
-
-#include <string.h>
-
-#include "bu/cmd.h"
-#include "bu/malloc.h"
-#include "bu/str.h"
-
-#define BU_CMDHIST_OBJ_LIST_INIT_CAPACITY 8
-
-/**
- * Stores the given command with start and finish times in the
- * history vls'es. 'status' is either BRLCAD_OK or BRLCAD_ERROR.
- */
-HIDDEN void
-cmdhist_record(struct bu_cmdhist_obj *chop, struct bu_vls *cmdp, struct
timeval *start, struct timeval *finish, int status)
-{
- struct bu_cmdhist *new_hist;
- const char *eol = "\n";
-
- if (UNLIKELY(BU_STR_EQUAL(bu_vls_addr(cmdp), eol)))
- return;
-
- if (chop->cmdhist.capacity == 0) {
- chop->cmdhist.capacity = BU_CMDHIST_OBJ_LIST_INIT_CAPACITY;
- chop->cmdhist.cmdhist = (struct bu_cmdhist *)bu_malloc(
- sizeof (struct bu_cmdhist) * chop->cmdhist.capacity,
- "init chop");
- } else if (chop->cmdhist.size == chop->cmdhist.capacity) {
- chop->cmdhist.capacity *= 2;
- chop->cmdhist.cmdhist = (struct bu_cmdhist *)bu_realloc(
- chop->cmdhist.cmdhist,
- sizeof (struct bu_cmdhist_obj) * chop->cmdhist.capacity,
- "init chop");
- }
-
- new_hist = &chop->cmdhist.cmdhist[chop->cmdhist.size];
- bu_vls_init(&new_hist->h_command);
- bu_vls_vlscat(&new_hist->h_command, cmdp);
- new_hist->h_start = *start;
- new_hist->h_finish = *finish;
- new_hist->h_status = status;
- chop->cmdhist.current = chop->cmdhist.size;
- chop->cmdhist.size++;
-}
-
-
-HIDDEN int
-cmdhist_timediff(struct timeval *tvdiff, struct timeval *start, struct timeval
*finish)
-{
- if (UNLIKELY(finish->tv_sec == 0 && finish->tv_usec == 0))
- return -1;
- if (UNLIKELY(start->tv_sec == 0 && start->tv_usec == 0))
- return -1;
-
- tvdiff->tv_sec = finish->tv_sec - start->tv_sec;
- tvdiff->tv_usec = finish->tv_usec - start->tv_usec;
- if (tvdiff->tv_usec < 0) {
- --tvdiff->tv_sec;
- tvdiff->tv_usec += 1000000L;
- }
-
- return 0;
-}
-
-
-int
-bu_cmdhist_history(void *data, int argc, const char *argv[])
-{
- FILE *fp;
- int with_delays = 0;
- struct bu_cmdhist *hp, *hp_prev;
- struct bu_vls str = BU_VLS_INIT_ZERO;
- struct timeval tvdiff;
- struct bu_cmdhist_obj *chop = (struct bu_cmdhist_obj *)data;
- size_t i;
-
- if (argc < 2 || 5 < argc) {
- bu_log("Usage: %s -delays\nList command history.\n", argv[0]);
- return BRLCAD_ERROR;
- }
-
- fp = NULL;
- while (argc >= 3) {
- const char *delays = "-delays";
- const char *outfile = "-outfile";
-
- if (BU_STR_EQUAL(argv[2], delays))
- with_delays = 1;
- else if (BU_STR_EQUAL(argv[2], outfile)) {
- if (fp != NULL) {
- fclose(fp);
- bu_log("%s: -outfile option given more than once\n", argv[0]);
- return BRLCAD_ERROR;
- } else if (argc < 4 || BU_STR_EQUAL(argv[3], delays)) {
- bu_log("%s: I need a file name\n", argv[0]);
- return BRLCAD_ERROR;
- } else {
- fp = fopen(argv[3], "ab+");
- if (UNLIKELY(fp == NULL)) {
- bu_log("%s: error opening file", argv[0]);
- return BRLCAD_ERROR;
- }
- --argc;
- ++argv;
- }
- } else {
- bu_log("Invalid option %s\n", argv[2]);
- }
- --argc;
- ++argv;
- }
-
- for (i = 1; i < chop->cmdhist.size; i++) {
- hp = &(chop->cmdhist.cmdhist[i]);
- hp_prev = &(chop->cmdhist.cmdhist[i - 1]);
- bu_vls_trunc(&str, 0);
- if (with_delays) {
- if (cmdhist_timediff(&tvdiff, &(hp_prev->h_finish), &(hp->h_start))
>= 0)
- bu_vls_printf(&str, "delay %ld %ld\n", (long)tvdiff.tv_sec,
- (long)tvdiff.tv_usec);
-
- }
-
- if (hp->h_status == BRLCAD_ERROR)
- bu_vls_printf(&str, "# ");
- bu_vls_vlscat(&str, &(hp->h_command));
-
- if (fp != NULL)
- bu_vls_fwrite(fp, &str);
- else
- bu_log("%s\n", bu_vls_addr(&str));
- }
-
- if (fp != NULL)
- fclose(fp);
-
- return BRLCAD_OK;
-}
-
-
-int
-bu_cmdhist_add(void *clientData, int argc, const char **argv)
-{
- struct bu_cmdhist_obj *chop = (struct bu_cmdhist_obj *)clientData;
- struct bu_vls vls = BU_VLS_INIT_ZERO;
- struct timeval zero;
-
- if (argc != 3) {
- bu_log("ERROR: expecting only three arguments\n");
- return BRLCAD_ERROR;
- }
-
- if (UNLIKELY(argv[2][0] == '\n' || argv[2][0] == '\0'))
- return BRLCAD_OK;
-
- bu_vls_strcpy(&vls, argv[2]);
- if (argv[2][strlen(argv[2])-1] != '\n')
- bu_vls_putc(&vls, '\n');
-
- zero.tv_sec = zero.tv_usec = 0L;
- cmdhist_record(chop, &vls, &zero, &zero, BRLCAD_OK);
-
- bu_vls_free(&vls);
-
- /* newly added command is in chop->cho_curr */
- return BRLCAD_OK;
-}
-
-
-int
-bu_cmdhist_prev(void *clientData, int argc, const char **UNUSED(argv))
-{
- struct bu_cmdhist_obj *chop = (struct bu_cmdhist_obj *)clientData;
-
- if (argc != 2) {
- bu_log("ERROR: expecting only two arguments\n");
- return BRLCAD_ERROR;
- }
-
- if (chop->cmdhist.capacity != 0 && chop->cmdhist.current > 0) {
- chop->cmdhist.current--;
- }
-
- /* result is at index chop->cmdhist.current */
- return BRLCAD_OK;
-}
-
-
-int
-bu_cmdhist_curr(void *clientData, int argc, const char **UNUSED(argv))
-{
- struct bu_cmdhist_obj *chop = (struct bu_cmdhist_obj *)clientData;
-
- if (argc != 2) {
- bu_log("ERROR: expecting only two arguments\n");
- return BRLCAD_ERROR;
- }
-
- if (chop->cmdhist.capacity > 0) {
- /* result is at index chop->cmdhist.current */
- return BRLCAD_OK;
- }
-
- /* no commands exist yet */
- return BRLCAD_ERROR;
-}
-
-
-int
-bu_cmdhist_next(void *clientData, int argc, const char **UNUSED(argv))
-{
- struct bu_cmdhist_obj *chop = (struct bu_cmdhist_obj *)clientData;
-
- if (argc != 2) {
- bu_log("ERROR: expecting only two arguments\n");
- return BRLCAD_ERROR;
- }
-
- if (chop->cmdhist.capacity == 0 ||
- chop->cmdhist.current == chop->cmdhist.size - 1) {
- return BRLCAD_ERROR;
- }
-
- chop->cmdhist.current++;
-
- /* result is at index chop->cmdhist.current */
- return BRLCAD_OK;
-}
-
-
-/*
- * Local Variables:
- * mode: C
- * tab-width: 8
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */
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