aboutsummaryrefslogtreecommitdiff
path: root/Converter/src/compiler.c
diff options
context:
space:
mode:
authordx <aryadevchavali1@gmail.com>2020-05-07 02:58:56 +0100
committerdx <aryadevchavali1@gmail.com>2020-05-07 02:58:56 +0100
commit510d6384033259be44b55e73283bafe38a53190a (patch)
tree7cb01255fc4dcd250010ba5f93dba119f4585092 /Converter/src/compiler.c
parent80c5f9a8129f5a151770b0979b9e39777cffb9f6 (diff)
downloadmdhtml-510d6384033259be44b55e73283bafe38a53190a.tar.gz
mdhtml-510d6384033259be44b55e73283bafe38a53190a.tar.bz2
mdhtml-510d6384033259be44b55e73283bafe38a53190a.zip
+find_string algorithm
This algorithm looks for substrings in a big string, attempting to find the index of the first occurence.
Diffstat (limited to 'Converter/src/compiler.c')
-rw-r--r--Converter/src/compiler.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Converter/src/compiler.c b/Converter/src/compiler.c
index 7efa032..df97c22 100644
--- a/Converter/src/compiler.c
+++ b/Converter/src/compiler.c
@@ -2,7 +2,14 @@
#include <stdio.h>
#include <string.h>
-void compile_inner_text(string dest, string src, size_t size_of_line,
+int find_string(string src, string query, size_t sz_src, size_t sz_query)
+{
+ int j = 0;
+ while ((j < (sz_src - sz_query)) && (strncmp(query, src + j, sz_query))) ++j;
+ return j;
+}
+
+void compile_inner_text(string dest, string src, size_t sz_src,
string line_or_source)
{
/* cursor is the current index on the dest pointer