From: Martin Quinson Date: Sun, 21 May 2017 00:04:54 +0000 (+0200) Subject: drop module strbuff. We don't need it anymore. X-Git-Tag: v3.16~281^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a60db7db98ac9e60384b1009120ae009bebc8c24 drop module strbuff. We don't need it anymore. Killing XBT (and reduce our maintainance burden) was a major motivation in the switch to C++. --- diff --git a/ChangeLog b/ChangeLog index c8464eece9..6ca3d3e3a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,7 +31,8 @@ SimGrid (3.16) UNRELEASED XBT - Replay: New function xbt_replay_action_get(): Retrieve the function previously associated to an event type. - - Drop unused functions: xbt_str_varsubst(), xbt_strbuff_varsubst() + - DROPPED FUNCTION: xbt_str_varsubst() + - DROPPED MODULE: strbuff. We don't need it anymore. -- Release target: June 21 2017 -- Da SimGrid team diff --git a/doc/doxygen/inside_tests.doc b/doc/doxygen/inside_tests.doc index 337344ae87..c8195c2dd2 100644 --- a/doc/doxygen/inside_tests.doc +++ b/doc/doxygen/inside_tests.doc @@ -72,7 +72,6 @@ your changes should look like that: --- a/tools/cmake/UnitTesting.cmake +++ b/tools/cmake/UnitTesting.cmake @@ -11,6 +11,7 @@ set(FILES_CONTAINING_UNITTESTS - src/xbt/xbt_strbuff.c src/xbt/xbt_sha.c src/xbt/config.c + src/xbt/plouf.c diff --git a/doc/doxygen/module-xbt.doc b/doc/doxygen/module-xbt.doc index 3f53b3681d..395f744cd4 100644 --- a/doc/doxygen/module-xbt.doc +++ b/doc/doxygen/module-xbt.doc @@ -18,7 +18,6 @@ - \ref XBT_dict - \ref XBT_swag - \ref XBT_heap - - @ref xbt_strbuff - \ref XBT_misc - \ref XBT_graph diff --git a/include/xbt.h b/include/xbt.h index c30e68523c..9d5510ec9f 100644 --- a/include/xbt.h +++ b/include/xbt.h @@ -19,7 +19,6 @@ #include #include -#include #include #include diff --git a/include/xbt/strbuff.h b/include/xbt/strbuff.h deleted file mode 100644 index 41bb52e435..0000000000 --- a/include/xbt/strbuff.h +++ /dev/null @@ -1,51 +0,0 @@ -/* strbuff -- string buffers */ - -/* Copyright (c) 2007-2011, 2013-2014. The SimGrid Team. - * All rights reserved. */ - -/* This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. */ - -#ifndef XBT_STRBUFF_H -#define XBT_STRBUFF_H - -#include "xbt/sysdep.h" -#include "xbt/function_types.h" -#include "xbt/log.h" -#include "xbt/str.h" -#include "xbt/dict.h" - -SG_BEGIN_DECL() - -/** @defgroup xbt_strbuff String buffers - * @ingroup XBT_adt - * - * This data container is very similar to the Java StringBuffer: - * that's a string to which you can add content with a lesser performance - * penalty than if you recreate a new string from scratch. Once done building - * your string, you must retrieve the content and free its container. - * - * @{ - */ - -/** @brief Buffer data container **/ -typedef struct xbt_strbuff { - char *data; - int used; - int size; -} s_xbt_strbuff_t; -typedef s_xbt_strbuff_t* xbt_strbuff_t; - -XBT_PUBLIC(void) xbt_strbuff_clear(xbt_strbuff_t b); -XBT_PUBLIC(xbt_strbuff_t) xbt_strbuff_new(void); -XBT_PUBLIC(xbt_strbuff_t) xbt_strbuff_new_from(const char *s); -XBT_PUBLIC(void) xbt_strbuff_free(xbt_strbuff_t b); -XBT_PUBLIC(void) xbt_strbuff_free_container(xbt_strbuff_t b); -XBT_PUBLIC(void) xbt_strbuff_append(xbt_strbuff_t b, const char *toadd); -XBT_PUBLIC(void) xbt_strbuff_printf(xbt_strbuff_t b, const char *fmt, ...); -XBT_PUBLIC(void) xbt_strbuff_chomp(xbt_strbuff_t b); -XBT_PUBLIC(void) xbt_strbuff_trim(xbt_strbuff_t b); - -/** @} */ -SG_END_DECL() -#endif diff --git a/src/surf/maxmin.cpp b/src/surf/maxmin.cpp index 0ab8b4d257..99fc2a16c2 100644 --- a/src/surf/maxmin.cpp +++ b/src/surf/maxmin.cpp @@ -8,7 +8,6 @@ #include "xbt/sysdep.h" #include "xbt/log.h" -#include "xbt/strbuff.h" #include "xbt/mallocator.h" #include "maxmin_private.hpp" #include diff --git a/src/xbt/log.c b/src/xbt/log.c index 86fd9c345a..44af691183 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -102,7 +102,6 @@ static void xbt_log_connect_categories(void) XBT_LOG_CONNECT(log); XBT_LOG_CONNECT(module); XBT_LOG_CONNECT(replay); - XBT_LOG_CONNECT(strbuff); XBT_LOG_CONNECT(xbt_cfg); XBT_LOG_CONNECT(xbt_dict); XBT_LOG_CONNECT(xbt_dict_cursor); diff --git a/src/xbt/xbt_log_layout_format.c b/src/xbt/xbt_log_layout_format.c index 78e5600b11..50a82e2094 100644 --- a/src/xbt/xbt_log_layout_format.c +++ b/src/xbt/xbt_log_layout_format.c @@ -7,7 +7,6 @@ #include "src/internal_config.h" /* execinfo when available */ #include "xbt/sysdep.h" -#include "xbt/strbuff.h" #include "src/xbt/log_private.h" #include "simgrid/simix.h" /* SIMIX_host_self_get_name */ #include "surf/surf.h" diff --git a/src/xbt/xbt_log_layout_simple.c b/src/xbt/xbt_log_layout_simple.c index c709fca855..6ec8eeb074 100644 --- a/src/xbt/xbt_log_layout_simple.c +++ b/src/xbt/xbt_log_layout_simple.c @@ -7,7 +7,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt/sysdep.h" -#include "xbt/strbuff.h" /* For dynamic version when the static one fails */ #include "src/xbt/log_private.h" #include "simgrid/simix.h" /* SIMIX_host_self_get_name */ diff --git a/src/xbt/xbt_str.cpp b/src/xbt/xbt_str.cpp index 68ee3604b5..76ad09e208 100644 --- a/src/xbt/xbt_str.cpp +++ b/src/xbt/xbt_str.cpp @@ -11,7 +11,6 @@ #include "xbt/misc.h" #include "xbt/sysdep.h" #include "xbt/str.h" /* headers of these functions */ -#include "xbt/strbuff.h" /** @brief Strip whitespace (or other characters) from the end of a string. * diff --git a/src/xbt/xbt_strbuff.c b/src/xbt/xbt_strbuff.c deleted file mode 100644 index e87d383c70..0000000000 --- a/src/xbt/xbt_strbuff.c +++ /dev/null @@ -1,89 +0,0 @@ -/* strbuff -- string buffers */ - -/* Copyright (c) 2007-2015. The SimGrid Team. - * All rights reserved. */ - -/* This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. */ - -#include "xbt/strbuff.h" -#include - -#define minimal_increment 512 - -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(strbuff, xbt, "String buffers"); - -/** @brief Remove any content from the buffer */ -inline void xbt_strbuff_clear(xbt_strbuff_t b) -{ - b->used = 0; - b->data[0] = '\0'; -} - -/** @brief Constructor */ -xbt_strbuff_t xbt_strbuff_new(void) -{ - xbt_strbuff_t res = xbt_malloc(sizeof(s_xbt_strbuff_t)); - res->data = xbt_malloc(512); - res->size = 512; - xbt_strbuff_clear(res); - return res; -} - -/** @brief creates a new string buffer containing the provided string - * - * Beware, the ctn is copied, you want to free it afterward, anyhow - */ -inline xbt_strbuff_t xbt_strbuff_new_from(const char *ctn) -{ - xbt_strbuff_t res = xbt_malloc(sizeof(s_xbt_strbuff_t)); - res->data = xbt_strdup(ctn); - res->size = strlen(ctn); - res->used = res->size; - return res; -} - -/** @brief frees only the container without touching to the contained string */ -inline void xbt_strbuff_free_container(xbt_strbuff_t b) -{ - free(b); -} - -/** @brief frees the buffer and its content */ -inline void xbt_strbuff_free(xbt_strbuff_t b) -{ - if (b) { - free(b->data); - free(b); - } -} - -/** @brief Adds some content at the end of the buffer */ -void xbt_strbuff_append(xbt_strbuff_t b, const char *toadd) -{ - int addlen; - int needed_space; - - xbt_assert(b, "Asked to append stuff to NULL buffer"); - - addlen = strlen(toadd); - needed_space = b->used + addlen + 1; - - if (needed_space > b->size) { - b->size = MAX(minimal_increment + b->used, needed_space); - b->data = xbt_realloc(b->data, b->size); - } - strncpy(b->data + b->used, toadd, b->size-b->used); - b->used += addlen; -} - -/** @brief format some content and push it at the end of the buffer */ -void xbt_strbuff_printf(xbt_strbuff_t b, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - char *data = bvprintf(fmt, ap); - xbt_strbuff_append(b, data); - xbt_free(data); - va_end(ap); -} diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index e513d437d6..b99f08e67a 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -288,7 +288,6 @@ set(XBT_SRC src/xbt/xbt_os_time.c src/xbt/xbt_replay.cpp src/xbt/xbt_str.cpp - src/xbt/xbt_strbuff.c src/xbt/xbt_virtu.c src/xbt_modinter.h ) @@ -734,7 +733,6 @@ set(headers_to_install include/xbt/range.hpp include/xbt/replay.hpp include/xbt/str.h - include/xbt/strbuff.h include/xbt/swag.h include/xbt/synchro.h include/xbt/sysdep.h diff --git a/tools/cmake/Distrib.cmake b/tools/cmake/Distrib.cmake index d13a04db76..6a536775a3 100644 --- a/tools/cmake/Distrib.cmake +++ b/tools/cmake/Distrib.cmake @@ -318,7 +318,6 @@ add_custom_target(maintainer-clean COMMAND ${CMAKE_COMMAND} -E remove -f src/simgrid_units_main.c COMMAND ${CMAKE_COMMAND} -E remove -f src/swag_unit.c COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_str_unit.c - COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_strbuff_unit.c COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_synchro_unit.c WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}") diff --git a/tools/cmake/GCCFlags.cmake b/tools/cmake/GCCFlags.cmake index 410bcb7fac..6615daadb2 100644 --- a/tools/cmake/GCCFlags.cmake +++ b/tools/cmake/GCCFlags.cmake @@ -124,7 +124,7 @@ if(enable_model-checking AND enable_compile_optimizations) src/xbt/xbt_log_layout_format.c src/xbt/xbt_log_layout_simple.c src/xbt/dict.cpp src/xbt/dict_elm.c src/xbt/dict_cursor.c src/xbt/dynar.cpp src/xbt/heap.c src/xbt/swag.c - src/xbt/str.c src/xbt/strbuff.c src/xbt/snprintf.c + src/xbt/str.c src src/xbt/snprintf.c src/xbt/queue.c src/xbt/xbt_os_time.c src/xbt/xbt_os_thread.c src/xbt/backtrace_linux.c diff --git a/tools/internal/spell_dict.txt b/tools/internal/spell_dict.txt index 4ba5bbbbee..48cc959b4f 100644 --- a/tools/internal/spell_dict.txt +++ b/tools/internal/spell_dict.txt @@ -91,7 +91,6 @@ smpi smx src std -strbuff strerror strlen struct