Files
C_C++
Cerbian
Tcl
anon_-_poller
autoconfig
bison
compile_times
cpp_zh
emil_header_guards
flex
flex_patter_vs_state
ill_show_you_xola
aaaaaaaa.y
brainfuck.c
hack.l
hw.l
modifications.txt
modifications_h2git.l
sections.l
segv_issue.c
segv_issue.l
linking
sds
1st_day_of_month.cpp
JJbY.cpp
Tp6G.cpp
access.c
alternatice_bracket.c
arrows.cpp
auto_variad.c
c.php
c_old_argument_notation.c
clear_bindings.c
cnn.c
comment_as_space.c
comp.c
compare_to.py
conditional_const.c
const.c
correct_c_equivalent.c
cpp_regex_error.cpp
current_year.cpp
dda2.cpp
does_freeing_a_const_char_pointer_warn_or_is_it_a_footgun_under_gcc.c
dog.jpg
dog2.jpg
eh.cpp
else_while.c
finalize_reprepare.c
for_ctags.cpp
for_nop_true.c
free_null.c
function_pointer_strategy.c
function_pointer_strategy2.c
gcc_include_next.c
gdb_graph.c
getopt_test.c
getter_example.cpp
gnu_decimals.c
gnu_history.c
gnu_regex.c
gnu_regex2.c
header.h
index_in_initializer_list_compiler_extension.c
is_this_what_you_are_asking_emil.c
knr.c
levenshtein_dist_-_usage.cpp
macro_paren.c
magic.c
manual_unrolling.c
map_initialization.cpp
ncurses_labels.c
ncurses_mv_win.cpp
ncurses_plus_readline.cpp
ncurses_resize2.cpp
ncurses_resize_hello_world.cpp
ncurses_resize_test.c
ncurses_scroll.c
nf.c
null_printf.c
null_printf.cpp
portable_namespace.c
portable_namespace.h
printf_star.c
pta.c
raylib_hw.cpp
scoping_showcase.c
screen_size_(without_curses).c
sdl_render_to_texture.cpp
self_pointer.c
sentinel_pack.c
setjmp_test.cpp
signals.c
strategiless.c
strdup.c
tcc_int.c
test.c
typedef.c
unctrl.c
undefined_reference.c
usb.c
vasprintf.c
void_main.c
x.cpp
xtermio.c
xtp.cpp
Haskell
Java
LaTeX
Misc.
Python
Vim
Webdev
git
.gitignore
Makefile
tests/C_C++/flex/modifications_h2git.l
2024-07-22 19:39:19 +02:00

75 lines
1.4 KiB
Plaintext

/* @BAKE
flex -o $*.yy.cpp $@
g++ $*.yy.cpp -o modifications_h2git.out -ggdb
@STOP
*/
%{
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
typedef struct {
string date;
string msg;
} commit_t;
commit_t commit_buffer = (commit_t){
.date = "N/A",
.msg = "N/A",
};
vector<commit_t> commits;
%}
%option noyywrap
%%
[0-9]+\/[0-9]+\/[0-9]{4} {
if (commit_buffer.msg != "N/A") {
commits.push_back(commit_buffer);
}
commit_buffer = (commit_t){
.date = "",
.msg = "",
};
commit_buffer.date = yytext;
}
\t|\*|\r { ; }
\n* { commit_buffer.msg += ' '; }
\" { commit_buffer.msg += "\\\""; }
. { commit_buffer.msg += yytext; }
%%
signed main(int argc, char * argv[]) {
if (argc != 2) {
printf("%s <modifications.h>", argv[0]);
return 1;
}
yyin = fopen(argv[1], "r");
yylex();
//for (auto i : commits) {
// printf("date: %s ; message: %s\n", i.date.c_str(), i.msg.c_str());
// puts("\033[31m-------\033[0m");
//}
// NOTE: https://unix.stackexchange.com/questions/3051/how-to-echo-a-bang
puts("histchars='¡^'");
for (auto i : commits) {
printf("git commit --allow-empty --date='%s 00:00:00' -m \"%s\"\n",
i.date.c_str(),
i.msg.c_str()
);
}
return 0;
}