mirror of
https://github.com/dongdigua/dongdigua.github.io
synced 2025-02-20 06:59:15 +08:00
new post: annoying project
This commit is contained in:
parent
9d39d166d5
commit
d213de2de7
1
.github/workflows/site.yml
vendored
1
.github/workflows/site.yml
vendored
@ -52,7 +52,6 @@ jobs:
|
||||
cd _site && tree
|
||||
sudo ./patches/icons.sh
|
||||
sudo ./patches/color.sh
|
||||
sudo patch -p1 < ./patches/bbs_gbk_utf8-highlight-adwaita.patch
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v1
|
||||
|
20
gmi/annoying_project.gmi
Normal file
20
gmi/annoying_project.gmi
Normal file
@ -0,0 +1,20 @@
|
||||
# Project that Annoys Me
|
||||
2023-03-31 Fri
|
||||
|
||||
First of all, I'm a noob to C.
|
||||
|
||||
I've been working on a project this month to experiment porting TUI application to ape[1].
|
||||
It was too hard for me, more than just modifying the build script (I also know little about it).
|
||||
|
||||
Tetris[2] in bsdgames, for example (actually I spent most time on it), uses termcap, which is not portable.
|
||||
|
||||
So I have to either write a "termcap" that only uses VT escape character,
|
||||
or just write some helper function like other Cosmopolitan projects[3].
|
||||
|
||||
I had no experience at all, I need to learn more, but where should I start from?
|
||||
HELP!
|
||||
|
||||
|
||||
=> https://justine.lol/ape.html [1]
|
||||
=> https://github.com/dongdigua/tetris-custom [2]
|
||||
=> https://github.com/shmup/awesome-cosmopolitan [3]
|
@ -139,9 +139,11 @@ uhh, 水族馆帧率没变...
|
||||
这个当然要自己编译, 今天 git.sv.gnu.org 特别慢, 而 github 快得离谱
|
||||
源码下载下来之后编译, 由于是纯 X, 所以选项和之前那篇[fn:6]里面的不一样
|
||||
着急用, 所以参数还没加全
|
||||
#+BEGIN_SRC ksh
|
||||
#+BEGIN_SRC shell
|
||||
./configure CFLAGS="-march=native -O3 -pipe -flto=thin -fstack-protector-strong" \
|
||||
--with-x --with-gif=ifavailable
|
||||
--with-x \
|
||||
--with-gif=ifavailable \
|
||||
--enable-link-time-optimization
|
||||
#+END_SRC
|
||||
然后就是各种依赖, 大多数 X 相关的系统都自带了
|
||||
之后各种包就容易了, 用我写的 =setup-what-pkg= 宏自动安装所有包
|
||||
@ -283,8 +285,6 @@ iwx0 at pci0 dev 20 function 3 "Intel Wi-Fi 6 AX201" rev 0x20, msix
|
||||
|
||||
我有时候会想访问 Linux 上的文件, 但是似乎不支持 btrfs...
|
||||
|
||||
** [[./bbs_gbk_utf8.org][支线任务: 中文 BBS GBK 转 UTF8]]
|
||||
|
||||
** [[https://github.com/dongdigua/tetris-custom][Add some useful feature in BSD Tetris]]
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: tetris
|
||||
|
@ -1,79 +0,0 @@
|
||||
--- ../bbs_gbk_utf8.html 2023-02-11 13:09:55.659432422 +0800
|
||||
+++ bbs_gbk_utf8.html 2023-02-11 13:29:23.784185878 +0800
|
||||
@@ -236,49 +236,49 @@
|
||||
<div class="org-src-container">
|
||||
-<pre class="src src-C"><span style="font-weight: bold;">#include</span> <span style="font-style: italic;"><stdio.h></span>
|
||||
-<span style="font-weight: bold;">#include</span> <span style="font-style: italic;"><iconv.h></span>
|
||||
+<pre class="src src-C"><span style="color: #e67e80;">#include</span> <span style="color: #4E9A06;"><stdio.h></span>
|
||||
+<span style="color: #e67e80;">#include</span> <span style="color: #4E9A06;"><iconv.h></span>
|
||||
|
||||
-<span style="font-weight: bold;">#define</span> <span style="font-weight: bold; font-style: italic;">UTF8_SIZE</span> 4
|
||||
+<span style="color: #e67e80;">#define</span> <span style="color: #0084C8; font-weight: bold;">UTF8_SIZE</span> 4
|
||||
|
||||
-<span style="font-weight: bold; text-decoration: underline;">int</span>
|
||||
-<span style="font-weight: bold;">convert_one</span>(<span style="font-weight: bold; text-decoration: underline;">iconv_t</span> <span style="font-weight: bold; font-style: italic;">cd</span>)
|
||||
+<span style="color: #2F8B58; font-weight: bold;">int</span>
|
||||
+<span style="color: #00578E; font-weight: bold;">convert_one</span>(<span style="color: #2F8B58; font-weight: bold;">iconv_t</span> <span style="color: #0084C8; font-weight: bold;">cd</span>)
|
||||
{
|
||||
- <span style="font-weight: bold; text-decoration: underline;">char</span> <span style="font-weight: bold; font-style: italic;">inbuf</span>[2] = {0};
|
||||
- <span style="font-weight: bold; text-decoration: underline;">char</span> <span style="font-weight: bold; font-style: italic;">outbuf</span>[UTF8_SIZE] = {0};
|
||||
- <span style="font-weight: bold; text-decoration: underline;">size_t</span> <span style="font-weight: bold; font-style: italic;">insize</span> = 1;
|
||||
- <span style="font-weight: bold; text-decoration: underline;">size_t</span> <span style="font-weight: bold; font-style: italic;">outsize</span> = UTF8_SIZE;
|
||||
-
|
||||
- <span style="font-weight: bold; text-decoration: underline;">char</span> <span style="font-weight: bold; font-style: italic;">c</span> = getchar();
|
||||
- <span style="font-weight: bold;">if</span> (c == EOF)
|
||||
- <span style="font-weight: bold;">return</span> 1;
|
||||
+ <span style="color: #2F8B58; font-weight: bold;">char</span> <span style="color: #0084C8; font-weight: bold;">inbuf</span>[2] = {0};
|
||||
+ <span style="color: #2F8B58; font-weight: bold;">char</span> <span style="color: #0084C8; font-weight: bold;">outbuf</span>[UTF8_SIZE] = {0};
|
||||
+ <span style="color: #2F8B58; font-weight: bold;">size_t</span> <span style="color: #0084C8; font-weight: bold;">insize</span> = 1;
|
||||
+ <span style="color: #2F8B58; font-weight: bold;">size_t</span> <span style="color: #0084C8; font-weight: bold;">outsize</span> = UTF8_SIZE;
|
||||
+
|
||||
+ <span style="color: #2F8B58; font-weight: bold;">char</span> <span style="color: #0084C8; font-weight: bold;">c</span> = getchar();
|
||||
+ <span style="color: #A52A2A; font-weight: bold;">if</span> (c == EOF)
|
||||
+ <span style="color: #A52A2A; font-weight: bold;">return</span> 1;
|
||||
inbuf[0] = c;
|
||||
|
||||
- <span style="font-weight: bold; text-decoration: underline;">char</span> * <span style="font-weight: bold; font-style: italic;">pIn</span> = inbuf;
|
||||
- <span style="font-weight: bold; text-decoration: underline;">char</span> * <span style="font-weight: bold; font-style: italic;">pOut</span> = (<span style="font-weight: bold; text-decoration: underline;">char</span>*) outbuf;
|
||||
+ <span style="color: #2F8B58; font-weight: bold;">char</span> * <span style="color: #0084C8; font-weight: bold;">pIn</span> = inbuf;
|
||||
+ <span style="color: #2F8B58; font-weight: bold;">char</span> * <span style="color: #0084C8; font-weight: bold;">pOut</span> = (<span style="color: #2F8B58; font-weight: bold;">char</span>*) outbuf;
|
||||
|
||||
- <span style="font-weight: bold; text-decoration: underline;">size_t</span> <span style="font-weight: bold; font-style: italic;">iconv_result</span> = iconv(cd, &pIn, &insize, &pOut, &outsize);
|
||||
- <span style="font-weight: bold;">if</span> (iconv_result == (<span style="font-weight: bold; text-decoration: underline;">size_t</span>) -1) {
|
||||
+ <span style="color: #2F8B58; font-weight: bold;">size_t</span> <span style="color: #0084C8; font-weight: bold;">iconv_result</span> = iconv(cd, &pIn, &insize, &pOut, &outsize);
|
||||
+ <span style="color: #A52A2A; font-weight: bold;">if</span> (iconv_result == (<span style="color: #2F8B58; font-weight: bold;">size_t</span>) -1) {
|
||||
inbuf[1] = getchar();
|
||||
insize = 2;
|
||||
iconv(cd, &pIn, &insize, &pOut, &outsize);
|
||||
}
|
||||
|
||||
- <span style="font-weight: bold;">for</span> (<span style="font-weight: bold; text-decoration: underline;">int</span> <span style="font-weight: bold; font-style: italic;">i</span> = 0; i < UTF8_SIZE; i++) {
|
||||
- <span style="font-weight: bold;">if</span> (outbuf[i] != 0)
|
||||
+ <span style="color: #A52A2A; font-weight: bold;">for</span> (<span style="color: #2F8B58; font-weight: bold;">int</span> <span style="color: #0084C8; font-weight: bold;">i</span> = 0; i < UTF8_SIZE; i++) {
|
||||
+ <span style="color: #A52A2A; font-weight: bold;">if</span> (outbuf[i] != 0)
|
||||
putchar(outbuf[i]);
|
||||
fflush(stdout);
|
||||
}
|
||||
- <span style="font-weight: bold;">return</span> 0;
|
||||
+ <span style="color: #A52A2A; font-weight: bold;">return</span> 0;
|
||||
}
|
||||
|
||||
-<span style="font-weight: bold; text-decoration: underline;">int</span>
|
||||
-<span style="font-weight: bold;">main</span>(<span style="font-weight: bold; text-decoration: underline;">void</span>)
|
||||
+<span style="color: #2F8B58; font-weight: bold;">int</span>
|
||||
+<span style="color: #00578E; font-weight: bold;">main</span>(<span style="color: #2F8B58; font-weight: bold;">void</span>)
|
||||
{
|
||||
- <span style="font-weight: bold; text-decoration: underline;">iconv_t</span> <span style="font-weight: bold; font-style: italic;">cd</span> = iconv_open(<span style="font-style: italic;">"UTF8"</span>, <span style="font-style: italic;">"GBK"</span>);
|
||||
- <span style="font-weight: bold;">while</span> (1)
|
||||
- <span style="font-weight: bold;">if</span> (convert_one(cd) == 1) <span style="font-weight: bold;">break</span>;
|
||||
+ <span style="color: #2F8B58; font-weight: bold;">iconv_t</span> <span style="color: #0084C8; font-weight: bold;">cd</span> = iconv_open(<span style="color: #4E9A06;">"UTF8"</span>, <span style="color: #4E9A06;">"GBK"</span>);
|
||||
+ <span style="color: #A52A2A; font-weight: bold;">while</span> (1)
|
||||
+ <span style="color: #A52A2A; font-weight: bold;">if</span> (convert_one(cd) == 1) <span style="color: #A52A2A; font-weight: bold;">break</span>;
|
||||
|
||||
iconv_close(cd);
|
||||
- <span style="font-weight: bold;">return</span> 0;
|
||||
+ <span style="color: #A52A2A; font-weight: bold;">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
</div>
|
||||
\ No newline at end of file
|
2
posts.md
2
posts.md
@ -1,7 +1,7 @@
|
||||
## Table of Contents
|
||||
### Posts (sorted by time)
|
||||
- [Project that Annoys Me](annoying_project.gmi.txt)<br>
|
||||
- [玩转邮件列表](mailinglist)<br>
|
||||
- [支线任务: 中文 BBS GBK 转 UTF8](bbs_gbk_utf8)<br>
|
||||
- [我要不要试试 OpenBSD](whatif_openbsd)<br>
|
||||
- [一个乐子 commit](lol.diff.txt)<br>
|
||||
- [一次大备份](backup_everything)<br>
|
||||
|
Loading…
Reference in New Issue
Block a user