mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-08-04 05:56:21 +00:00
revert: restore pre-upstream-merge baseline (tree of 3b673150b)
Roll the tree back to the pre-merge tip3b673150b, undoing the upstream sync merge72f4f186d(303 files) and the 13 post-merge commits layered on top of it. Purpose: restore the last pre-sync baseline so the reported OMEMO/OTR encryption regressions can be reproduced against a known-good state and the upstream sync ruled in or out as the cause. Nothing is dropped from history; the merge and every post-merge commit remain reachable and can be cherry-picked back selectively. Baseline:3b673150bchore(chatlog): disable background message file logging (stage 1) Undoes merge:72f4f186dmerge: sync upstream profanity-im/profanity
This commit is contained in:
@@ -3,9 +3,35 @@
|
||||
* vim: expandtab:ts=4:sts=4:sw=4
|
||||
*
|
||||
* Copyright (C) 2019 Aurelien Aptel <aurelien.aptel@gmail.com>
|
||||
* Copyright (C) 2019 - 2026 Michael Vetter <jubalh@iodoru.org>
|
||||
* Copyright (C) 2019 - 2025 Michael Vetter <jubalh@iodoru.org>
|
||||
*
|
||||
* This file is part of Profanity.
|
||||
*
|
||||
* Profanity is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Profanity is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Profanity. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link the code of portions of this program with the OpenSSL library under
|
||||
* certain conditions as described in each individual source file, and
|
||||
* distribute linked combinations including the two.
|
||||
*
|
||||
* You must obey the GNU General Public License in all respects for all of the
|
||||
* code used other than OpenSSL. If you modify file(s) with this exception, you
|
||||
* may extend this exception to your version of the file(s), but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version. If you delete this exception statement from all
|
||||
* source files in the program, then also delete it here.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later WITH OpenSSL-exception
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@@ -33,7 +59,7 @@ static struct color_pair_cache
|
||||
{
|
||||
struct
|
||||
{
|
||||
short fg, bg;
|
||||
int16_t fg, bg;
|
||||
}* pairs;
|
||||
int size;
|
||||
int capacity;
|
||||
@@ -315,18 +341,14 @@ color_distance(const struct color_def* a, const struct color_def* b)
|
||||
return h * h + s * s + l * l;
|
||||
}
|
||||
|
||||
/* Indices into the 256-colour palette and ncurses palette IDs are
|
||||
* 16-bit (the size_t-or-short distinction in ncurses init_pair).
|
||||
* Use `short` end-to-end so the caller boundaries don't need casts.
|
||||
*/
|
||||
static short
|
||||
static int
|
||||
find_closest_col(int h, int s, int l)
|
||||
{
|
||||
struct color_def a = { (uint16_t)h, (uint8_t)s, (uint8_t)l, NULL };
|
||||
short min = 0;
|
||||
struct color_def a = { h, s, l };
|
||||
int min = 0;
|
||||
int dmin = color_distance(&a, &color_names[0]);
|
||||
|
||||
for (short i = 1; i < COLOR_NAME_SIZE; i++) {
|
||||
for (int i = 1; i < COLOR_NAME_SIZE; i++) {
|
||||
int d = color_distance(&a, &color_names[i]);
|
||||
if (d < dmin) {
|
||||
dmin = d;
|
||||
@@ -336,8 +358,8 @@ find_closest_col(int h, int s, int l)
|
||||
return min;
|
||||
}
|
||||
|
||||
static short
|
||||
find_col(const char* col_name, size_t n)
|
||||
static int
|
||||
find_col(const char* col_name, int n)
|
||||
{
|
||||
char name[32] = { 0 };
|
||||
|
||||
@@ -349,7 +371,7 @@ find_col(const char* col_name, size_t n)
|
||||
|
||||
if (n >= sizeof(name)) {
|
||||
/* truncate */
|
||||
log_error("Color: <%s,%zu> bigger than %zu", col_name, n, sizeof(name));
|
||||
log_error("Color: <%s,%d> bigger than %zu", col_name, n, sizeof(name));
|
||||
n = sizeof(name) - 1;
|
||||
}
|
||||
memcpy(name, col_name, n);
|
||||
@@ -358,7 +380,7 @@ find_col(const char* col_name, size_t n)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (short i = 0; i < COLOR_NAME_SIZE; i++) {
|
||||
for (int i = 0; i < COLOR_NAME_SIZE; i++) {
|
||||
if (g_ascii_strcasecmp(name, color_names[i].name) == 0) {
|
||||
return i;
|
||||
}
|
||||
@@ -367,13 +389,13 @@ find_col(const char* col_name, size_t n)
|
||||
return COL_ERR;
|
||||
}
|
||||
|
||||
static short
|
||||
static int
|
||||
color_hash(const char* str, color_profile profile)
|
||||
{
|
||||
GChecksum* cs = NULL;
|
||||
guint8 buf[256] = { 0 };
|
||||
gsize len = 256;
|
||||
short rc = -1; /* default ncurse color */
|
||||
int rc = -1; /* default ncurse color */
|
||||
|
||||
cs = g_checksum_new(G_CHECKSUM_SHA1);
|
||||
if (!cs)
|
||||
@@ -442,7 +464,7 @@ color_pair_cache_reset(void)
|
||||
}
|
||||
|
||||
static int
|
||||
_color_pair_cache_get(short fg, short bg)
|
||||
_color_pair_cache_get(int fg, int bg)
|
||||
{
|
||||
if (COLORS < 256) {
|
||||
if (fg > 7 || bg > 7) {
|
||||
@@ -467,13 +489,10 @@ _color_pair_cache_get(short fg, short bg)
|
||||
}
|
||||
|
||||
int i = cache.size;
|
||||
// TODO: init_pair uses 15-bit palette indices. Terminals exposing
|
||||
// extended colour palettes (>32767) need init_extended_pair here.
|
||||
// Upstream-inherited limitation.
|
||||
cache.pairs[i].fg = fg;
|
||||
cache.pairs[i].bg = bg;
|
||||
/* (re-)define the new pair in curses */
|
||||
init_pair((short)i, fg, bg);
|
||||
init_pair(i, fg, bg);
|
||||
|
||||
cache.size++;
|
||||
|
||||
@@ -492,8 +511,8 @@ _color_pair_cache_get(short fg, short bg)
|
||||
int
|
||||
color_pair_cache_hash_str(const char* str, color_profile profile)
|
||||
{
|
||||
short fg = color_hash(str, profile);
|
||||
short bg = -1;
|
||||
int fg = color_hash(str, profile);
|
||||
int bg = -1;
|
||||
|
||||
auto_char char* bkgnd = theme_get_bkgnd();
|
||||
if (bkgnd) {
|
||||
@@ -513,7 +532,7 @@ int
|
||||
color_pair_cache_get(const char* pair_name)
|
||||
{
|
||||
const char* sep;
|
||||
short fg, bg;
|
||||
int fg, bg;
|
||||
|
||||
sep = strchr(pair_name, '_');
|
||||
if (!sep) {
|
||||
@@ -521,7 +540,7 @@ color_pair_cache_get(const char* pair_name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
fg = find_col(pair_name, (size_t)(sep - pair_name));
|
||||
fg = find_col(pair_name, sep - pair_name);
|
||||
bg = find_col(sep + 1, strlen(sep));
|
||||
if (fg == COL_ERR || bg == COL_ERR) {
|
||||
log_error("Color: bad color name %s", pair_name);
|
||||
|
||||
Reference in New Issue
Block a user