fixed file loading bug
parent
fe951cd92e
commit
e8405a5c04
|
@ -169,6 +169,10 @@ FSTRING_LINK fstr_bool remove_extension(String *str);
|
|||
FSTRING_LINK fstr_bool remove_last_folder(String *str);
|
||||
FSTRING_LINK fstr_bool string_set_match_table(void *str_set, int32_t item_size, int32_t count, String str, int32_t *match_index);
|
||||
FSTRING_LINK fstr_bool string_set_match(String *str_set, int32_t count, String str, int32_t *match_index);
|
||||
FSTRING_LINK String get_first_double_line(String source);
|
||||
FSTRING_LINK String get_next_double_line(String source, String line);
|
||||
FSTRING_LINK String get_next_word(String source, String prev_word);
|
||||
FSTRING_LINK String get_first_word(String source);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1919,6 +1923,84 @@ string_set_match(String *str_set, int32_t count, String str, int32_t *match_inde
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(FSTRING_IMPLEMENTATION)
|
||||
FSTRING_LINK String
|
||||
get_first_double_line(String source){
|
||||
String line = {0};
|
||||
int32_t pos0 = find_substr_s(source, 0, make_lit_string("\n\n"));
|
||||
int32_t pos1 = find_substr_s(source, 0, make_lit_string("\r\n\r\n"));
|
||||
if (pos1 < pos0){
|
||||
pos0 = pos1;
|
||||
}
|
||||
line = substr(source, 0, pos0);
|
||||
return(line);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FSTRING_IMPLEMENTATION)
|
||||
FSTRING_LINK String
|
||||
get_next_double_line(String source, String line){
|
||||
String next = {0};
|
||||
int32_t pos = (int32_t)(line.str - source.str) + line.size;
|
||||
int32_t start = 0, pos0 = 0, pos1 = 0;
|
||||
|
||||
if (pos < source.size){
|
||||
//Assert(source.str[pos] == '\n' || source.str[pos] == '\r');
|
||||
start = pos + 1;
|
||||
|
||||
if (start < source.size){
|
||||
pos0 = find_substr_s(source, start, make_lit_string("\n\n"));
|
||||
pos1 = find_substr_s(source, start, make_lit_string("\r\n\r\n"));
|
||||
if (pos1 < pos0){
|
||||
pos0 = pos1;
|
||||
}
|
||||
next = substr(source, start, pos0 - start);
|
||||
}
|
||||
}
|
||||
|
||||
return(next);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FSTRING_IMPLEMENTATION)
|
||||
FSTRING_LINK String
|
||||
get_next_word(String source, String prev_word){
|
||||
|
||||
String word = {0};
|
||||
int32_t pos0 = (int32_t)(prev_word.str - source.str) + prev_word.size;
|
||||
int32_t pos1 = 0;
|
||||
char c = 0;
|
||||
|
||||
for (; pos0 < source.size; ++pos0){
|
||||
c = source.str[pos0];
|
||||
if (!(char_is_whitespace(c) || c == '(' || c == ')')){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos0 < source.size){
|
||||
for (pos1 = pos0; pos1 < source.size; ++pos1){
|
||||
c = source.str[pos1];
|
||||
if (char_is_whitespace(c) || c == '(' || c == ')'){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
word = substr(source, pos0, pos1 - pos0);
|
||||
}
|
||||
|
||||
return(word);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FSTRING_IMPLEMENTATION)
|
||||
FSTRING_LINK String
|
||||
get_first_word(String source){
|
||||
String start_str = make_string(source.str, 0);
|
||||
String word = get_next_word(source, start_str);
|
||||
return(word);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FSTRING_EXPERIMENTAL
|
||||
#define FSTRING_EXPERIMENTAL
|
||||
|
|
10
4ed.cpp
10
4ed.cpp
|
@ -361,6 +361,8 @@ COMMAND_DECL(reopen){
|
|||
|
||||
if (buffer){
|
||||
if (system->load_file(handle, buffer, size)){
|
||||
system->load_close(handle);
|
||||
|
||||
General_Memory *general = &models->mem.general;
|
||||
|
||||
File_Edit_Positions edit_poss[16];
|
||||
|
@ -395,11 +397,15 @@ COMMAND_DECL(reopen){
|
|||
file->settings.unwrapped_lines);
|
||||
}
|
||||
}
|
||||
else{
|
||||
system->load_close(handle);
|
||||
}
|
||||
}
|
||||
else{
|
||||
system->load_close(handle);
|
||||
}
|
||||
|
||||
end_temp_memory(temp);
|
||||
|
||||
system->load_close(handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1091,6 +1091,7 @@ DOC_SEE(begin_buffer_creation)
|
|||
}
|
||||
|
||||
if (system->load_file(handle, buffer, size)){
|
||||
system->load_close(handle);
|
||||
file = working_set_alloc_always(system, working_set, general);
|
||||
if (file){
|
||||
buffer_bind_file(system, general, working_set, file, canon.name);
|
||||
|
@ -1099,12 +1100,13 @@ DOC_SEE(begin_buffer_creation)
|
|||
fill_buffer_summary(&result, file, cmd);
|
||||
}
|
||||
}
|
||||
else{
|
||||
system->load_close(handle);
|
||||
}
|
||||
|
||||
if (in_general_mem){
|
||||
general_memory_free(system, general, buffer);
|
||||
}
|
||||
|
||||
system->load_close(handle);
|
||||
}
|
||||
else if (!(flags & BufferCreate_NeverNew)){
|
||||
file = working_set_alloc_always(system, working_set, general);
|
||||
|
|
|
@ -3792,10 +3792,12 @@ view_open_file(System_Functions *system, Models *models, View *view, String file
|
|||
}
|
||||
|
||||
if (system->load_file(handle, buffer, size)){
|
||||
system->load_close(handle);
|
||||
init_normal_file(system, models, file, buffer, size);
|
||||
}
|
||||
|
||||
else{
|
||||
system->load_close(handle);
|
||||
}
|
||||
|
||||
if (gen_buffer){
|
||||
general_memory_free(system, general, buffer);
|
||||
|
|
12
build.cpp
12
build.cpp
|
@ -822,17 +822,17 @@ do_buildsuper(char *cdir){
|
|||
//terminate_with_null(&str);
|
||||
//buildsuper(cdir, BUILD_DIR, str.str);
|
||||
#if defined(IS_WINDOWS)
|
||||
copy_sc(&str, "../code/internal_4coder_tests.cpp");
|
||||
terminate_with_null(&str);
|
||||
buildsuper(cdir, BUILD_DIR, str.str);
|
||||
//copy_sc(&str, "../code/internal_4coder_tests.cpp");
|
||||
//terminate_with_null(&str);
|
||||
//buildsuper(cdir, BUILD_DIR, str.str);
|
||||
#else
|
||||
copy_sc(&str, "../code/power/4coder_experiments.cpp");
|
||||
terminate_with_null(&str);
|
||||
buildsuper(cdir, BUILD_DIR, str.str);
|
||||
#endif
|
||||
//copy_sc(&str, "../code/power/4coder_casey.cpp");
|
||||
//terminate_with_null(&str);
|
||||
//buildsuper(cdir, BUILD_DIR, str.str);
|
||||
copy_sc(&str, "../code/power/4coder_casey.cpp");
|
||||
terminate_with_null(&str);
|
||||
buildsuper(cdir, BUILD_DIR, str.str);
|
||||
//copy_sc(&str, "../4vim/4coder_chronal.cpp");
|
||||
//terminate_with_null(&str);
|
||||
//buildsuper(cdir, BUILD_DIR, str.str);
|
||||
|
|
|
@ -1799,6 +1799,76 @@ DOC_SEE(match) */{
|
|||
return(result);
|
||||
}
|
||||
|
||||
API_EXPORT FSTRING_LINK String
|
||||
get_first_double_line(String source){
|
||||
String line = {0};
|
||||
int32_t pos0 = find_substr_s(source, 0, make_lit_string("\n\n"));
|
||||
int32_t pos1 = find_substr_s(source, 0, make_lit_string("\r\n\r\n"));
|
||||
if (pos1 < pos0){
|
||||
pos0 = pos1;
|
||||
}
|
||||
line = substr(source, 0, pos0);
|
||||
return(line);
|
||||
}
|
||||
|
||||
API_EXPORT FSTRING_LINK String
|
||||
get_next_double_line(String source, String line){
|
||||
String next = {0};
|
||||
int32_t pos = (int32_t)(line.str - source.str) + line.size;
|
||||
int32_t start = 0, pos0 = 0, pos1 = 0;
|
||||
|
||||
if (pos < source.size){
|
||||
//Assert(source.str[pos] == '\n' || source.str[pos] == '\r');
|
||||
start = pos + 1;
|
||||
|
||||
if (start < source.size){
|
||||
pos0 = find_substr_s(source, start, make_lit_string("\n\n"));
|
||||
pos1 = find_substr_s(source, start, make_lit_string("\r\n\r\n"));
|
||||
if (pos1 < pos0){
|
||||
pos0 = pos1;
|
||||
}
|
||||
next = substr(source, start, pos0 - start);
|
||||
}
|
||||
}
|
||||
|
||||
return(next);
|
||||
}
|
||||
|
||||
API_EXPORT FSTRING_LINK String
|
||||
get_next_word(String source, String prev_word){
|
||||
|
||||
String word = {0};
|
||||
int32_t pos0 = (int32_t)(prev_word.str - source.str) + prev_word.size;
|
||||
int32_t pos1 = 0;
|
||||
char c = 0;
|
||||
|
||||
for (; pos0 < source.size; ++pos0){
|
||||
c = source.str[pos0];
|
||||
if (!(char_is_whitespace(c) || c == '(' || c == ')')){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos0 < source.size){
|
||||
for (pos1 = pos0; pos1 < source.size; ++pos1){
|
||||
c = source.str[pos1];
|
||||
if (char_is_whitespace(c) || c == '(' || c == ')'){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
word = substr(source, pos0, pos1 - pos0);
|
||||
}
|
||||
|
||||
return(word);
|
||||
}
|
||||
|
||||
API_EXPORT FSTRING_LINK String
|
||||
get_first_word(String source){
|
||||
String start_str = make_string(source.str, 0);
|
||||
String word = get_next_word(source, start_str);
|
||||
return(word);
|
||||
}
|
||||
|
||||
#ifndef FSTRING_EXPERIMENTAL
|
||||
#define FSTRING_EXPERIMENTAL
|
||||
|
|
Binary file not shown.
|
@ -268,17 +268,64 @@ write_enriched_text_html(String *out, Enriched_Text *text){
|
|||
|
||||
append_sc(out, "<div>");
|
||||
|
||||
// TODO(allen): get this working
|
||||
#if 0
|
||||
for (String line = get_first_double_line(source);
|
||||
line.str;
|
||||
line = get_next_double_line(chunk, line)){
|
||||
line = get_next_double_line(source, line)){
|
||||
String l = skip_chop_whitespace(line);
|
||||
append_sc(out, "<p>");
|
||||
append_ss(out, line);
|
||||
|
||||
//append_ss(out, l);
|
||||
int32_t start = 0, i = 0;
|
||||
for (; i < l.size; ++i){
|
||||
if (l.str[i] == '\\'){
|
||||
append_ss(out, substr(l, start, i-start));
|
||||
|
||||
int32_t command_start = i+1;
|
||||
int32_t command_end = command_start;
|
||||
for (; command_end < l.size; ++command_end){
|
||||
if (!char_is_alpha_numeric(l.str[command_end])){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (command_end == command_start){
|
||||
if (command_end < l.size && l.str[command_end] == '\\'){
|
||||
++command_end;
|
||||
}
|
||||
}
|
||||
|
||||
String command_string = substr(l, command_start, command_end - command_start);
|
||||
|
||||
static String enriched_commands[] = {
|
||||
make_lit_string("\\"),
|
||||
make_lit_string("VERSION"),
|
||||
make_lit_string("CODE_STYLE"),
|
||||
};
|
||||
|
||||
int32_t match_index = 0;
|
||||
if (string_set_match(enriched_commands, ArrayCount(enriched_commands), command_string, &match_index)){
|
||||
switch (match_index){
|
||||
case 0: append_sc(out, "\\"); break;
|
||||
case 1: append_sc(out, VERSION); break;
|
||||
case 2: append_sc(out, "<span style='"HTML_CODE_STYLE"'> TEST </span>"); break;
|
||||
}
|
||||
}
|
||||
else{
|
||||
append_sc(out,"<span style='color:#F00'>! Doc generator error: unrecognized command !</span>");
|
||||
fprintf(stderr, "error: Unrecognized command %.*s\n", command_string.size, command_string.str);
|
||||
}
|
||||
|
||||
i = command_end;
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (start != i){
|
||||
append_ss(out, substr(l, start, i-start));
|
||||
}
|
||||
|
||||
append_sc(out, "</p>");
|
||||
}
|
||||
#endif
|
||||
append_ss(out, source);
|
||||
|
||||
append_sc(out, "</div>");
|
||||
}
|
||||
|
@ -292,7 +339,9 @@ doc_item_head_html(String *out, Document_Item *item, Section_Counter section_cou
|
|||
"<html lang=\"en-US\">"
|
||||
"<head>"
|
||||
"<title>");
|
||||
|
||||
append_ss(out, item->section.name);
|
||||
|
||||
append_sc(out,
|
||||
"</title>"
|
||||
"<style>"
|
||||
|
|
|
@ -186,77 +186,6 @@ print_macro_html(String *out, String name, Argument_Breakdown breakdown){
|
|||
#define EXAMPLE_CODE_OPEN "<div style='"CODE_STYLE EXAMPLE_CODE_STYLE"'>"
|
||||
#define EXAMPLE_CODE_CLOSE "</div>"
|
||||
|
||||
// TODO(allen): move string iteration utils somewhere cooler (4coder_string.h?)
|
||||
static String
|
||||
get_first_double_line(String source){
|
||||
String line = {0};
|
||||
int32_t pos0 = find_substr_s(source, 0, make_lit_string("\n\n"));
|
||||
int32_t pos1 = find_substr_s(source, 0, make_lit_string("\r\n\r\n"));
|
||||
if (pos1 < pos0){
|
||||
pos0 = pos1;
|
||||
}
|
||||
line = substr(source, 0, pos0);
|
||||
return(line);
|
||||
}
|
||||
|
||||
static String
|
||||
get_next_double_line(String source, String line){
|
||||
String next = {0};
|
||||
int32_t pos = (int32_t)(line.str - source.str) + line.size;
|
||||
int32_t start = 0, pos0 = 0, pos1 = 0;
|
||||
|
||||
if (pos < source.size){
|
||||
assert(source.str[pos] == '\n' || source.str[pos] == '\r');
|
||||
start = pos + 1;
|
||||
|
||||
if (start < source.size){
|
||||
pos0 = find_substr_s(source, start, make_lit_string("\n\n"));
|
||||
pos1 = find_substr_s(source, start, make_lit_string("\r\n\r\n"));
|
||||
if (pos1 < pos0){
|
||||
pos0 = pos1;
|
||||
}
|
||||
next = substr(source, start, pos0 - start);
|
||||
}
|
||||
}
|
||||
|
||||
return(next);
|
||||
}
|
||||
|
||||
static String
|
||||
get_next_word(String source, String prev_word){
|
||||
String word = {0};
|
||||
int32_t pos0 = (int32_t)(prev_word.str - source.str) + prev_word.size;
|
||||
int32_t pos1 = 0;
|
||||
char c = 0;
|
||||
|
||||
for (; pos0 < source.size; ++pos0){
|
||||
c = source.str[pos0];
|
||||
if (!(char_is_whitespace(c) || c == '(' || c == ')')){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos0 < source.size){
|
||||
for (pos1 = pos0; pos1 < source.size; ++pos1){
|
||||
c = source.str[pos1];
|
||||
if (char_is_whitespace(c) || c == '(' || c == ')'){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
word = substr(source, pos0, pos1 - pos0);
|
||||
}
|
||||
|
||||
return(word);
|
||||
}
|
||||
|
||||
static String
|
||||
get_first_word(String source){
|
||||
String start_str = make_string(source.str, 0);
|
||||
String word = get_next_word(source, start_str);
|
||||
return(word);
|
||||
}
|
||||
|
||||
enum Doc_Chunk_Type{
|
||||
DocChunk_PlainText,
|
||||
DocChunk_CodeExample,
|
||||
|
@ -1092,14 +1021,14 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
|
|||
|
||||
append_sc(&out,
|
||||
"<div>"
|
||||
"<p>This is the documentation for " VERSION " The documentation is still "
|
||||
"<p>This is the documentation for " VERSION ". The documentation is still "
|
||||
"under construction so some of the links are linking to sections that "
|
||||
"have not been written yet. What is here should be correct and I suspect "
|
||||
"useful even without some of the other sections.</p>"
|
||||
"<p>If you have questions or discover errors please contact "
|
||||
"<span style='"CODE_STYLE"'>editor@4coder.net</span> or "
|
||||
"to get help from community members you can post on the "
|
||||
"4coder forums hosted on handmade.network at "
|
||||
"to get help from members of the 4coder and handmade network community you "
|
||||
"can post on the 4coder forums hosted at "
|
||||
"<span style='"CODE_STYLE"'>4coder.handmade.network</span></p>"
|
||||
"</div>");
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
This is the documentation for the 4cpp lexer version 1.1. The documentation is the newest piece of this lexer project so it may still have problems. What is here should be correct and mostly complete.
|
||||
This is the documentation for \VERSION. The documentation is still under construction so some of the links are linking to sections that have not been written yet. What is here should be correct and I suspect useful even without some of the other sections.
|
||||
|
||||
If you have questions or discover errors please contact \CODE_STYLE{editor@4coder.net} or to get help from members of the 4coder and handmade network community you can post on the 4coder forums hosted at \CODE_STYLE{4coder.handmade.network}
|
||||
If you have questions or discover errors please contact \CODE_STYLE{editor@4coder.net} or to get help from members of the 4coder and handmade network community you can post on the 4coder forums hosted at \CODE_STYLE{4coder.handmade.network}.
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
This is the documentation for the 4cpp lexer version \VERSION. The documentation is the newest piece of this lexer project so it may still have problems. What is here should be correct and mostly complete.
|
||||
|
||||
If you have questions or discover errors please contact \CODE_STYLE{editor@4coder.net} or to get help from members of the 4coder and handmade network community you can post on the 4coder forums hosted at \CODE_STYLE{4coder.handmade.network}.
|
Loading…
Reference in New Issue