c-md/srcs/utils/string/extract_fence_ext.c.md
lohhiiccc 80f7a1b9b6 feat(build): add build instructions in README and convert sources to .c.md format
- Add detailed build and bootstrap instructions to README.md.
 - Convert all source and header files from .c/.h to .c.md/.h.md.
 - Add bootstrap.sh script for automated building across version history.
 - Update Makefile and sources.mk to reflect new markdown-based source organization.
2026-01-12 14:54:49 +01:00

625 B

#include <stdlib.h>
#include <string.h>
#include <stdint.h>

#include "utils.h"

char *
extract_fence_ext(const char *fence)
{
	const char	*start;
	const char	*end;
	size_t		len;
	char		*ext;

	if (0 != strncmp(fence, "```", 3))
		return (NULL);
	start = fence + 3;
	while (' ' == *start || '\t' == *start)
		start++;
	if ('\n' == *start || '\0' == *start)
		return (NULL);
	end = start;
	while ('\n' != *end && '\0' != *end && ' ' != *end && '\t' != *end)
		end++;
	len = (size_t)(end - start);
	ext = malloc(len + 1);
	if (NULL == ext)
		return (NULL);
	memcpy(ext, start, len);
	ext[len] = '\0';
	return (ext);
}