FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 07-04-2011, 02:16 AM
Allan McRae
 
Default Simplify alpm_list_previous

We can readily detect the first node in a list by checking if
node->prev->next is NULL. So there is no need to pass the head
of the list to this function and its prototype now looks like
all the other item accessors.

Signed-off-by: Allan McRae <allan@archlinux.org>
---
lib/libalpm/alpm_list.c | 7 +++----
lib/libalpm/alpm_list.h | 2 +-
lib/libalpm/remove.c | 4 ++--
3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
index 38cefa6..071cd99 100644
--- a/lib/libalpm/alpm_list.c
+++ b/lib/libalpm/alpm_list.c
@@ -547,11 +547,10 @@ inline alpm_list_t SYMEXPORT *alpm_list_next(const alpm_list_t *node)
*
* @return the previous element, or NULL when no previous element exist
*/
-inline alpm_list_t SYMEXPORT *alpm_list_previous(const alpm_list_t *list,
- const alpm_list_t *node)
+inline alpm_list_t SYMEXPORT *alpm_list_previous(const alpm_list_t *list)
{
- if(node && node != list) {
- return node->prev;
+ if(list && list->prev->next) {
+ return list->prev;
} else {
return NULL;
}
diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h
index 824e866..5e8ca46 100644
--- a/lib/libalpm/alpm_list.h
+++ b/lib/libalpm/alpm_list.h
@@ -69,7 +69,7 @@ alpm_list_t *alpm_list_reverse(alpm_list_t *list);
/* item accessors */
alpm_list_t *alpm_list_nth(const alpm_list_t *list, size_t n);
alpm_list_t *alpm_list_next(const alpm_list_t *list);
-alpm_list_t *alpm_list_previous(const alpm_list_t *list, const alpm_list_t *node);
+alpm_list_t *alpm_list_previous(const alpm_list_t *list);
alpm_list_t *alpm_list_last(const alpm_list_t *list);
void *alpm_list_getdata(const alpm_list_t *entry);

diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 59374dc..9b8517c 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -329,7 +329,7 @@ int _alpm_upgraderemove_package(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG, "removing %ld files
", (unsigned long)filenum);

/* iterate through the list backwards, unlinking files */
- for(lp = alpm_list_last(files); lp; lp = alpm_list_previous(files, lp)) {
+ for(lp = alpm_list_last(files); lp; lp = alpm_list_previous(lp)) {
unlink_file(handle, oldpkg, lp->data, skip_remove, 0);
}
FREELIST(skip_remove);
@@ -406,7 +406,7 @@ int _alpm_remove_packages(alpm_handle_t *handle)
pkg_count, (pkg_count - targcount + 1));

/* iterate through the list backwards, unlinking files */
- for(lp = alpm_list_last(files); lp; lp = alpm_list_previous(files, lp)) {
+ for(lp = alpm_list_last(files); lp; lp = alpm_list_previous(lp)) {
int percent;
unlink_file(handle, info, lp->data, NULL, trans->flags & ALPM_TRANS_FLAG_NOSAVE);

--
1.7.6



Mon Jul 4 05:30:01 2011
Return-path: <users-bounces@lists.fedoraproject.org>
Envelope-to: tom@linux-archive.org
Delivery-date: Mon, 04 Jul 2011 05:10:28 +0300
Received: from bastion02.fedoraproject.org ([209.132.181.3]:55351 helo=bastion.fedoraproject.org)
by s2.java-tips.org with esmtp (Exim 4.69)
(envelope-from <users-bounces@lists.fedoraproject.org>)
id 1QdYcG-00039z-Ho
for tom@linux-archive.org; Mon, 04 Jul 2011 05:10:28 +0300
Received: from lists.fedoraproject.org (collab1.vpn.fedoraproject.org [192.168.1.21])
by bastion02.phx2.fedoraproject.org (Postfix) with ESMTP id 962E9110C4C;
Mon, 4 Jul 2011 02:14:17 +0000 (UTC)
Received: from collab1.fedoraproject.org (localhost.localdomain [127.0.0.1])
by lists.fedoraproject.org (Postfix) with ESMTP id BB5773267A1;
Mon, 4 Jul 2011 02:14:16 +0000 (UTC)
X-Original-To: users@lists.fedoraproject.org
Delivered-To: users@lists.fedoraproject.org
Received: from smtp-mm01.fedoraproject.org (smtp-mm01.fedoraproject.org
[80.239.156.217])
by lists.fedoraproject.org (Postfix) with ESMTP id 5B2A33267A0
for <users@lists.fedoraproject.org>;
Mon, 4 Jul 2011 02:14:14 +0000 (UTC)
Received: from smtp507.mail.kks.yahoo.co.jp (smtp507.mail.kks.yahoo.co.jp
[114.111.99.156])
by smtp-mm01.fedoraproject.org (Postfix) with SMTP id 9E65087E5F
for <users@lists.fedoraproject.org>;
Mon, 4 Jul 2011 02:14:12 +0000 (UTC)
Received: (qmail 38918 invoked by alias); 4 Jul 2011 02:14:09 -0000
Received: from unknown (HELO ?192.168.1.12?) (111.168.155.120 with plain)
by smtp507.mail.kks.yahoo.co.jp with SMTP; 4 Jul 2011 02:14:09 -0000
X-Apparently-From: <supergiantpotato@yahoo.co.jp>
Subject: Re: Gnome Q: Application window save-data for restore when reopened?
From: =?UTF-8?Q?=E5=A4=9C=E7=A5=9E_=E5=B2=A9=E7=94=B7?=
<supergiantpotato@yahoo.co.jp>
To: users@lists.fedoraproject.org
In-Reply-To: <4E10BD24.6080502@cdkkt.com>
References: <4E10BD24.6080502@cdkkt.com>
Date: Mon, 04 Jul 2011 11:14:07 +0900
Message-ID: <1309745647.14981.31.camel@ika.shinden.murasaki>
Mime-Version: 1.0
X-Mailer: Evolution 2.32.2 (2.32.2-1.fc14)
X-BeenThere: users@lists.fedoraproject.org
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: Community support for Fedora users <users@lists.fedoraproject.org>
List-Id: Community support for Fedora users <users.lists.fedoraproject.org>
List-Unsubscribe: <https://admin.fedoraproject.org/mailman/listinfo/users>,
<mailto:users-request@lists.fedoraproject.org?subject=unsubscrib e>
List-Archive: <http://lists.fedoraproject.org/pipermail/users>
List-Post: <mailto:users@lists.fedoraproject.org>
List-Help: <mailto:users-request@lists.fedoraproject.org?subject=help>
List-Subscribe: <https://admin.fedoraproject.org/mailman/listinfo/users>,
<mailto:users-request@lists.fedoraproject.org?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: users-bounces@lists.fedoraproject.org
Errors-To: users-bounces@lists.fedoraproject.org

On Sun, 2011-07-03 at 12:04 -0700, Daniel B. Thurman wrote:
> I am sorry if this question was asked before,
> but I was wondering why is it, that most app-
> lication's main window do not restore it's
> last save-data the next time it is opened?
> What I am talking about is window position
> and size data, but not limited to these only.

This is an issue that exists per-application. It has been possible to
have an application remember its most recent settings for as long as I
can remember, and that detail has been overlooked by most new projects
in their first few iterations for as long as I can remember.

> How many times does an application have to be
> repositioned & resized every time it is opened?

42.

> Further, is there a Gnome application design framework,
> that includes built-in support for application save-data
> which include things as position, size, workspace location
> session-save hooks, and any window specific save-data
> so that designers will automatically have this code when
> developing new windows applications? (Yeah, dream on?)

This already exists. Most people writing their first app just don't
focus on this sort of thing, and the issue often goes overlooked for a
very long time before someone in the upstream project realizes "Bagh! My
highly useful application is really irritating to resize all the time!"

> It would also be nice if this was standardized, so that a
> Desktop configuration tool would recognize these apps
> and allow for Global & User property changes saved
> either in the the global or user's (~/.config "database")
> or whatever is appropriate.

This would be very difficult to implement because it would require
crystal-ball technology. How would a global settings file/function
anticipate the creation of all new apps, window libraries and possible
locations in the future and make a slot for each of them?

The standardish way of handling this (and this is the same on Windows,
OSX and our Linux constellation of window managers) is to have the
application record its last state in a file somewhere in the users home
directory. Usually if you go hunting through your dot folders you can
find current state data or cumulative data for an app inside an XML or
other data file in there somewhere.

A good open source example is X-chat's ~/.xchat2/xchat.conf file.

A good example in a multi-platform closed source app would be Skype's
~/.Skype/shared.xml file.

Whenever an application doesn't behave like this, it is usually the
fault of the application, not the window manager. The place to focus
your attention is upstream. Either patch the application to add this
sort of functionality (fairly easy to do if you've got experience, and
if not a good way to start learning the libraries involved in your
favorite apps), or bug upstream to do it.

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 07-04-2011, 07:28 AM
Xavier Chantry
 
Default Simplify alpm_list_previous

On Mon, Jul 4, 2011 at 4:16 AM, Allan McRae <allan@archlinux.org> wrote:
> We can readily detect the first node in a list by checking if
> node->prev->next is NULL. So there is no need to pass the head
> of the list to this function and its prototype now looks like
> all the other item accessors.
>

This works even for single item list where the first item is the last,
so node->prev == node.
ACK
 

Thread Tools




All times are GMT. The time now is 07:01 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org