M .gitignore => .gitignore +8 -0
@@ 1,3 1,11 @@
.DS_Store
+aclocal.m4
+autoscan.log
+autom4te.cache
+build-aux
+config.h.in
+configure
+configure.scan
+Makefile.in
tmp
A Makefile.am => Makefile.am +13 -0
@@ 0,0 1,13 @@
+AM_CPPFLAGS = -D_GNU_SOURCE
+AM_CFLAGS = -std=c99
+
+lib_LIBRARIES = libastr.a
+include_HEADERS = astr.h
+libastr_a_SOURCES = astr.c
+
+LDDADD = $(lib_LIBRARIES)
+check_PROGRAMS = astr_tests
+TESTS = $(check_PROGRAMS)
+
+EXTRA_DIST = LICENSE README.md
+
M README.md => README.md +14 -2
@@ 4,12 4,24 @@ A C99 library for working with dynamically allocated strings.
## Dependencies
`astr` requires that `<stdio.h>` defines the [`vasprintf()`][1] function.
+Building from repository source requires [GNU Autotools][2].
[1]: http://man7.org/linux/man-pages/man3/asprintf.3.html
+[2]: https://www.gnu.org/software/automake/faq/autotools-faq.html
+
+## Building from Repository Source
+
+Clone the repository then generate the `configure` script, configure and build.
+
+ git clone https://git.sr.ht/~donmcc/astr
+ cd astr
+ autoreconf -i
+ mkdir tmp && cd tmp
+ ../configure && make && sudo make install
## License
-`astr` is made available under a BSD-style license; see the [LICENSE][2] file
+`astr` is made available under a BSD-style license; see the [LICENSE][3] file
for details.
-[2]: https://git.sr.ht/~donmcc/astr/tree/master/LICENSE
+[3]: https://git.sr.ht/~donmcc/astr/tree/master/LICENSE
A astr.c => astr.c +6 -0
@@ 0,0 1,6 @@
+#include "astr.h"
+
+
+extern char *
+astr_alloc_empty(void);
+
A astr.h => astr.h +16 -0
@@ 0,0 1,16 @@
+#ifndef ASTR_H_INCLUDED
+#define ASTR_H_INCLUDED
+
+
+#include <stdlib.h>
+
+
+inline char *
+astr_alloc_empty(void)
+{
+ return calloc(1, sizeof(char));
+}
+
+
+#endif
+
A astr_tests.c => astr_tests.c +22 -0
@@ 0,0 1,22 @@
+#include <assert.h>
+#include <string.h>
+#include "astr.h"
+
+
+static void
+test_astr_alloc_empty(void)
+{
+ char *s = astr_alloc_empty();
+ assert(s);
+ assert(0 == strlen(s));
+ free(s);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ test_astr_alloc_empty();
+ return EXIT_SUCCESS;
+}
+
A configure.ac => configure.ac +36 -0
@@ 0,0 1,36 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.69])
+AC_INIT([astr], [0.1], [don@donm.cc])
+AC_CONFIG_AUX_DIR([build-aux])
+
+AM_INIT_AUTOMAKE([1.14 foreign subdir-objects -Wall -Werror])
+
+AC_CONFIG_SRCDIR([astr.h])
+AC_CONFIG_HEADERS([config.h])
+
+# Checks for programs.
+AM_PROG_AR
+AC_PROG_CC_C99
+AC_PROG_INSTALL
+AC_PROG_MKDIR_P
+AC_PROG_RANLIB
+
+# Checks for libraries.
+
+# Checks for header files.
+AC_HEADER_STDBOOL
+AC_CHECK_HEADERS([stdlib.h string.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_INLINE
+AC_TYPE_SIZE_T
+
+# Checks for library functions.
+AC_CHECK_FUNC([vasprintf])
+
+AC_CONFIG_FILES([Makefile])
+
+AC_OUTPUT
+